可以使用键盘(向上和向下箭头键)导航第一个示例。
<TreeView BorderThickness="0">
<TreeViewItem>
<TreeViewItem.Header>
<TextBlock>Parent</TextBlock>
</TreeViewItem.Header>
<TreeViewItem.Items>
<TreeViewItem>
<TreeViewItem.Header>
<TextBlock>Child</TextBlock>
</TreeViewItem.Header>
</TreeViewItem>
</TreeViewItem.Items>
</TreeViewItem>
</TreeView>
第二个包含超链接,键盘导航崩溃(向上和向下箭头键)。
<TreeView BorderThickness="0">
<TreeViewItem>
<TreeViewItem.Header>
<TextBlock>Parent</TextBlock>
</TreeViewItem.Header>
<TreeViewItem.Items>
<TreeViewItem>
<TreeViewItem.Header>
<TextBlock>
<Hyperlink>
Child
</Hyperlink>
</TextBlock>
</TreeViewItem.Header>
</TreeViewItem>
</TreeViewItem.Items>
</TreeViewItem>
</TreeView>
考虑到我对
WPF/XAML
不熟悉,我做错了什么或我错过了什么?使用VS 2015.1
和.NET 4.6
。
例外是:
System.InvalidOperationException: 'System.Windows.Documents.Hyperlink' is not a Visual or Visual3D.
at MS.Internal.Media.VisualTreeUtils.AsVisual(DependencyObject element, Visual& amp; visual, Visual3D&amp; visual3D)
at System.Windows.Media.VisualTreeHelper.GetParent(DependencyObject reference)
at System.Windows.Controls.TreeViewItem.AllowHandleKeyEvent(FocusNavigationDirection direction)
at System.Windows.Controls.TreeViewItem.HandleUpDownKey(Boolean up, KeyEventArgs e)
at System.Windows.Controls.TreeViewItem.OnKeyDown(KeyEventArgs e)
at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
at System.Windows.Input.InputManager.ProcessStagingArea()
at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
at System.Windows.Interop.HwndKeyboardInputProvider.ProcessKeyAction(MSG& amp; msg, Boolean&amp; handled)
at System.Windows.Interop.HwndSource.CriticalTranslateAccelerator(MSG& amp; msg, ModifierKeys modifiers)
at System.Windows.Interop.HwndSource.OnPreprocessMessage(Object param)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
at System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority priority, Delegate method, Object arg)
at System.Windows.Interop.HwndSource.OnPreprocessMessageThunk(MSG& amp; msg, Boolean&amp; handled)
at System.Windows.Interop.ComponentDispatcherThread.RaiseThreadMessage(MSG& amp; msg)
at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
at System.Windows.Application.RunDispatcher(Object ignore)
at System.Windows.Application.RunInternal(Window window)
在Microsoft Connect上添加了错误报告。谁知道......