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

蹲街弑〆低调 提交于 2019-12-03 10:41:08

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"));
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!