I made a TreeViewComboBox control, this I have a ComboBox with items such as TreeView, but keyboard navigation Does not work on the tree view I am not able to navigate through the tree view using the keyboard. Any help plz?
I have a similar problem when implementing our property grid control our This issue in specific, which can be , is identical to you, that there were no routing for the event with keyboard focus, TreeViewItem .
The way we dealt with it, it is done by adding a Atantproprti Tree Viaiaiaitim style and when her keyboard receiving focus Select node I find it a < Employed using the em> service pattern, see below:
In XAML:
style x: key = " EditorBorder "TargetType =" {x: type limit} "& gt; & Lt; Setter Property = "Controlls_services: Tree ViITMS Service. Select the keyboardsisfcoxed" value = "true" /> & Lt; / Style & gt; in codebehind:
public class TreeViewItemService {public static DependencyProperty read only SelectWhenKeyboardIsFocusedProperty = DependencyProperty.RegisterAttached ( "SelectWhenKeyboardIsFocused ", typeof (bool), typeof (TreeViewItemService), new FrameworkPropertyMetadata (wrong, TreeViewItemService.OnSelectWhenKeyboardIsFocusedPropertyChanged)); As static void OnSelectWhenKeyboardIsFocusedPropertyChanged FrameworkElement (object sender, DependencyPropertyChangedEventArgs e) {FrameworkElement element = this; If return (element == blank); TreeViewItem target = MTVisualTreeHelper.FindParent & lt; TreeViewItem & gt; (Element as dependent object); If (Target! = Faucet) New IsSelectedOnKeyboardFocusAction (element, target); } Public Stable Boole GetSelectWhenKeyboardIsFocused (Framework Element Target) {Return (bool) target.GetValue (SelectWhenKeyboardIsFocusedProperty); } Public Fixed Zero SetSelectWhenKeyboardIsFocused (Framework Element Target, Boole Value) {target.SetValue (SelectWhenKeyboardIsFocusedProperty, Value); } Private Class IsSelectedOnKeyboardFocusAction {TreeViewItem m_Target; Framework Element m_Source; Public IsSelectedOnKeyboardFocusAction (Framework Element Source, Tryvytim Item) {m_Source = source; M_Target = item; M_Source.Loaded + = OnSource_Loaded; M_Source.Unloaded + = OnSource_Unloaded; } Void OnSource_Loaded (object sender, RoutedEventArgs e) {m_Source.PreviewMouseLeftButtonDown + = OnSource_PreviewMouseLeftButtonDown; M_Source.GotFocus + = OnSource_GotFocus; M_Source.LostFocus + = OnSource_LostFocus; M_Source.GotKeyboardFocus + = OnSource_GotKeyboardFocus; M_Source.LostKeyboardFocus + = OnSource_LostKeyboardFocus; } Zero OnSource_Unloaded (Object Sender, RoutedEventArgs E) {m_Source.PreviewMouseLeftButtonDown - = OnSource_PreviewMouseLeftButtonDown; M_Source.GotFocus - = OnSource_GotFocus; M_Source.LostFocus - = OnSource_LostFocus; M_Source.GotKeyboardFocus - = OnSource_GotKeyboardFocus; M_Source.LostKeyboardFocus - = OnSource_LostKeyboardFocus; } Zero OnSource_PreviewMouseLeftButtonDown (Object Sender, MouseButtonEventArgs e) {if m_Target.IsSelected = true (m_Target.IsSelected!); } Zero OnSource_GotFocus (Object Sender, RoutedEventArgs E) {if selected! (M_Target.Is selected) m_Target.Is selected = true; } Zero OnSource_LostFocus (Object Sender, RoutedEventArgs E) {if (m_Target.Is selected) m_Target.Isselected = false; } Zero OnSource_GotKeyboardFocus (Object Sender, KeyboardFocusChangedEventArgs E) {if selected! (M_Target.Is selected) m_Target.Is selected = true; } Zero OnSource_LostKeyboardFocus (Object Sender, KeyboardFocusChangedEventArgs E) {if (m_Target.Is selected) m_Target.Isselected = false; }}} hh,
Comments
Post a Comment