void OnTreeViewItemKeyboardAccept(object sender, KeyEventArgs e) { var item = sender as TreeViewItem; if (null != item && item.Header is ExpanderTypeEntry) { this.SelectedTypeEntry = (ExpanderTypeEntry)item.Header; } if (null != item && item.IsSelected && item.IsSelectionActive && Key.Enter == e.Key && Keyboard.Modifiers == ModifierKeys.None) { this.Accept(item); e.Handled = true; } }
void OnTreeViewItemMouseAccept(object sender, MouseButtonEventArgs e) { var item = sender as TreeViewItem; if (null != item && item.Header is ExpanderTypeEntry) { this.SelectedTypeEntry = (ExpanderTypeEntry)item.Header; } if (null != item && item.IsSelected && item.IsSelectionActive) { this.Accept(item); e.Handled = true; } }
void Accept(TreeViewItem item) { bool isType = item.Header is ExpanderTypeEntry; bool isMember = item.Header is MemberInfo; if (isMember) { var members = new List <MemberInfo>(1); while (null != item && item.Header is MemberInfo) { var member = (MemberInfo)item.Header; members.Insert(0, member); if (item.Tag is TreeViewItem) { item = (TreeViewItem)item.Tag; } else { item = null; } } this.SelectedTypeEntry = (ExpanderTypeEntry)item.Header; this.selectedType = this.SelectedTypeEntry.TypeToExpand; this.path = members.ToArray(); } else if (isType) { this.SelectedTypeEntry = (ExpanderTypeEntry)item.Header; this.selectedType = this.SelectedTypeEntry.TypeToExpand; this.path = new MemberInfo[0]; } else { this.SelectedTypeEntry = null; this.selectedType = null; this.path = null; } this.IsSelectionValid = isType || isMember; this.RaiseEvent(new RoutedEventArgs(SelectionChangedEvent, this)); }
void Accept(TreeViewItem item) { bool isType = item.Header is ExpanderTypeEntry; bool isMember = item.Header is MemberInfo; if (isMember) { var members = new List<MemberInfo>(1); while (null != item && item.Header is MemberInfo) { var member = (MemberInfo)item.Header; members.Insert(0, member); if (item.Tag is TreeViewItem) { item = (TreeViewItem)item.Tag; } else { item = null; } } this.SelectedTypeEntry = (ExpanderTypeEntry)item.Header; this.selectedType = this.SelectedTypeEntry.TypeToExpand; this.path = members.ToArray(); } else if (isType) { this.SelectedTypeEntry = (ExpanderTypeEntry)item.Header; this.selectedType = this.SelectedTypeEntry.TypeToExpand; this.path = new MemberInfo[0]; } else { this.SelectedTypeEntry = null; this.selectedType = null; this.path = null; } this.IsSelectionValid = isType || isMember; this.RaiseEvent(new RoutedEventArgs(SelectionChangedEvent, this)); }