[英]Disabling keyboard navigation in WPF ListBox
如何在WPF列表框中禁用键盘导航而不禁用使用鼠标的选择?
将PreviewKeyDown
事件处理为并将e.Handled
设置为true(您可以仅检查和禁用与传递给处理程序的KeyEventArgs一起提供的某些键/修饰符):
XAML:
<ListBox PreviewKeyDown="listBox_PreviewKeyDown">
<ListBoxItem Content="asdfasdf" />
<ListBoxItem Content="asdfasdf" />
<ListBoxItem Content="asdfasdf" />
</ListBox>
后面的代码:
private void listBox_PreviewKeyDown(object sender, KeyEventArgs e)
{
e.Handled = true;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.