0
定義済みのジェスチャーによって、メソッドXceedCopyCommandExecuteを実行しようとしましたが、このメソッドは一度も呼び出されていません。このジェスチャーを使用するときは、列ヘッダーで行全体をコピーするだけです。 withnout headercolumnをコピーしないようにしてください。どのようにそれを解決するための任意のアイデア?何かアドバイスctrl + cまたはshift + cでコピー反応がありません
public static RoutedCommand XceedCopyCommand = new RoutedCommand();
public CommandBinding XceedCopyCommandBinding { get { return xceedCopyCommandBinding; } }
private CommandBinding xceedCopyCommandBinding;
public BaseView()
{
XceedCopyCommand.InputGestures.Add(new KeyGesture(Key.C, ModifierKeys.Control | ModifierKeys.Shift));
xceedCopyCommandBinding = new CommandBinding(XceedCopyCommand, XceedCopyCommandExecuted);
}
private void XceedCopyCommandExecuted(object sender, ExecutedRoutedEventArgs e)
{
if (sender == null || !(sender is Xceed.Wpf.DataGrid.DataGridControl)) return;
var dataGrid = sender as Xceed.Wpf.DataGrid.DataGridControl;
dataGrid.ClipboardExporters[DataFormats.UnicodeText].IncludeColumnHeaders = false;
var currentRow = dataGrid.GetContainerFromItem(dataGrid.CurrentItem) as Xceed.Wpf.DataGrid.Row;
if (currentRow == null) return;
var currentCell = currentRow.Cells[dataGrid.CurrentColumn];
if (currentCell != null && currentCell.HasContent)
{
Clipboard.SetText(currentCell.Content.ToString());
}
}