Exemplo n.º 1
0
        void ProcessGotFocus(RoutedEventArgs e)
        {
            if (base.SelectedIndex < 0)
            {
                base.SelectedIndex = 0;
            }
            ListBoxItem targetElement = base.ContainerFromItem(base.SelectedItem) as ListBoxItem;

            if ((targetElement != null) && !ElementTreeHelper.IsKeyboardFocusWithin(targetElement))
            {
                targetElement.Focus(FocusState.Programmatic);
            }
        }
Exemplo n.º 2
0
 int GetFocusedItemIndex()
 {
     if (ElementTreeHelper.IsKeyboardFocusWithin(ItemsPresenter))
     {
         return(0);
     }
     if (ElementTreeHelper.IsFocused(OKButton))
     {
         return(1);
     }
     if (ElementTreeHelper.IsFocused(CancelButton))
     {
         return(2);
     }
     return(-1);
 }
Exemplo n.º 3
0
 void ProcessFocus()
 {
     if ((base.SelectedIndex < 0) && (base.Items.Count > 0))
     {
         base.SelectedIndex = 0;
     }
     if ((base.SelectedIndex >= 0) && (base.SelectedIndex < base.Items.Count))
     {
         ListBoxItem targetElement = base.ContainerFromIndex(base.SelectedIndex) as ListBoxItem;
         if (targetElement == null)
         {
             base.ScrollIntoView(base.SelectedItem);
             targetElement = base.ContainerFromIndex(base.SelectedIndex) as ListBoxItem;
         }
         if ((targetElement != null) && !ElementTreeHelper.IsKeyboardFocusWithin(targetElement))
         {
             targetElement.Focus(FocusState.Programmatic);
         }
     }
 }