WPF DataGrid, Copy to Clipboard after Ctrl+C,OnCopyingRowClipboardContent WPF DataGrid, Copy to Clipboard after Ctrl+C,OnCopyingRowClipboardContent wpf wpf

WPF DataGrid, Copy to Clipboard after Ctrl+C,OnCopyingRowClipboardContent


the correct way is add on XAML grid this property

ClipboardCopyMode="ExcludeHeader"

and for each property you want copy add this XAML

 <DataGridTemplateColumn  ClipboardContentBinding="{Binding XXXXXX} ..... 

other facultative step is implement the dataGrid event CopyingRowClipboardContent to modify the clipoard data


You need to set the ClipboardRowContent property of DataGridRowClipboardEventArgs

static void dataGrid_CopyingRowClipboardContent(object sender, DataGridRowClipboardEventArgs e){    e.ClipboardRowContent.Clear();    e.ClipboardRowContent.Add(new DataGridClipboardCellContent(e.Item, (sender as DataGrid).Columns[0], "Abc-hello"));}