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);
}