Microsoft.Windows.Controls.Ribbon.RibbonGalleryItem.OnLostKeyboardFocus C# (CSharp) Method

OnLostKeyboardFocus() protected method

An event announcing that the keyboard is no longer focused
protected OnLostKeyboardFocus ( System.Windows.Input.KeyboardFocusChangedEventArgs e ) : void
e System.Windows.Input.KeyboardFocusChangedEventArgs Event arguments
return void
        protected override void OnLostKeyboardFocus(KeyboardFocusChangedEventArgs e)
        {
            // ShouldGalleryITemsAcquireFocus is set on the first Gallery in a RibbonComboBox.
            // If this flag is set GalleryItems do not acquire focus upon being Highlighted.
            // On the same lines we shouldn't be de-highlighting upon loss of focus either.
            // The scenario for loss of focus arises when the GalleryItem is navigated to via
            // regular keyboard navigation logic from a sibling RibbonMenuItem or Gallery.
            // In this case RibbonComboBox has logic to reacquire focus itself. But we do not
            // want this operation to trigger a dehighlight.

            if (e.OriginalSource == this && RibbonGallery != null && RibbonGallery.ShouldGalleryItemsAcquireFocus)
            {
                IsPressed = false;
                IsHighlighted = false;
                e.Handled = true;
            }

            base.OnLostKeyboardFocus(e);
        }