By defined gesture try to execute method XceedCopyCommandExecute, but this method has never been call. And when use this gesture, it just copy whole row with column header. Try to avoid to copy withnout headercolumn. Any idea how to solve it ?
Thank in advance for any advice
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());
}
}