I really need help to figure out how to add a context menu for a specific column on a datagrid.
Currently my datagrid looks like this: Datagrid and all columns are added to the datagrid dynamically with the itemsource: ItemsSource="{Binding Data.DefaultView}"
and I have AutoGenerateColumns="True". Currently I can add different contextmenu for all the headers by using a style and a trigger. Example:
<Style TargetType="{x:Type DataGridColumnHeader}">
<Style.Triggers>
<Trigger Property="Content" Value="CoreRefDes">
<Setter Property="ContextMenu"
Value="{StaticResource DataGridColumnHeaderContextMenuSpecific}" />
</Trigger>
<Trigger Property="Content" Value="CorePartNumber">
<Setter Property="ContextMenu"
Value="{StaticResource DataGridColumnHeaderContextMenuSpecific}" />
</Trigger>
<Trigger Property="Content" Value="CoreDescription">
<Setter Property="ContextMenu"
Value="{StaticResource DataGridColumnHeaderContextMenuSpecific}" />
</Trigger>
<Trigger Property="Content" Value="Split">
<Setter Property="ContextMenu"
Value="{StaticResource DataGridColumnHeaderContextMenuSpecific}" />
</Trigger>
</Style.Triggers>
I want something similar but instead of the contextmenu on the header I want it on the cells or the datagrid based on the header name. Currently my contextmenu appears on the datagrid like this:
<Style TargetType="{x:Type DataGrid}">
<Setter Property="ContextMenu" Value="{DynamicResource DatagridCellContextmenuItems}"/>
</Style>
Problem with this is I get the same contextmenu for all the columns. I want a different contextmenu for column 1 and 2. Any idea on how to solve this?
Thank you very much!