已解决,代码更改如下:
-
- public RelayCommand<KeyEventArgs> GridKeyDownCopyCommand
- {
- get
- {
- return new RelayCommand<KeyEventArgs>(e =>
- {
- var grid = e.Source as C1DataGrid;
- if (grid != null && e.KeyboardDevice.Modifiers == ModifierKeys.Control && e.Key == Key.C)
- {
- if (grid.CurrentCell != null)
- {
- string data = grid.CurrentCell.Text;
- Clipboard.SetDataObject(data, false);
- e.Handled = true;// 如果该单元可编辑,防止键入“C”
- }
- }
- });
- }
- }
复制代码 |