I've done ContextMenus before but for a DataGrid they seem to be far too complex. I just want to copy the content of the cell into the clipboard. How can I get this working? Seems like there are many alternatives, but no set guaranteed method.
<DataGrid ItemsSource="{Binding MyStuff}">
<DataGridTextColumn Binding="{Binding MyContentIWantToCopy}">
<DataGridTextColumn.CellStyle>
<Setter Property="ContextMenu">
<Setter.Value>
<ContextMenu>
<MenuItem Command="ApplicationCommands.Copy"/>
</ContextMenu>
</Setter.Value>
</Setter>
<DataGridTextColumn.CellStyle>
</DataGridTextColumn>
</DataGrid>
Ideally this would be the simplest way. But of course, it does not work.
However, I've also tried Commands -
Paste from Excel to WPF DataGrid
MVVM binding command to contextmenu item
Create contextmenus for datagrid rows
None of these work. Typically the result is a context menu that appears and either a greyed out button or one that doesn't do anything, never triggers the command. I just want to copy the text inside the Datagrid cell into the clipboard. I've done this on all kinds of objects before in similar manner - even Listviews - but I can't find any solution for DataGrid and DataGridTextColumns.