2011-01-09 107 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