protected override void OnGotKeyboardFocus(KeyboardFocusChangedEventArgs e)
{
base.OnGotKeyboardFocus(e);
FrameworkElement currentSelection = CurrentSelection;
if (currentSelection != null &&
IsDropDownOpen)
{
UIElement popupChild = _popup.TryGetChild();
if (popupChild != null &&
!popupChild.IsKeyboardFocusWithin)
{
// If the drop down is open and the currentselection is valid
// but still popup doesnt have focus within,
// then focus the current selection.
currentSelection.Focus();
}
}
}