緣由暫時未找到。this
有如下幾個解決方案: 1、在發生該問題的控件上添加Handler,而後添加方法捕捉 示例:在Page的Constructor中:this.AddHandler(DataGrid.PreviewKeyDownEvent, new RoutedEventHandler(Page_PreviewKeyDown)); 處理方法 private void Page_PreviewKeyDown(object sender, RoutedEventArgs e) { if (e.OriginalSource.GetType().Name == typeof(DataGridCell).Name || e.OriginalSource.GetType().Name == typeof(DataGrid).Name) { e.Handled = true; } }
這個能夠放在全局的窗體上去作
2、與上面相似,在wpf控件自己添加KeyDown方法 <Grid KeyDown="Grid_KeyDown"> private void Grid_KeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Back) { e.Handled = true; } }