2011-01-09 108 views

回答

5

处理的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; 
} 
+0

你能提供C#代码?我没有学会视觉基础。 – 2011-01-09 14:04:34