I am trying to add a context menu to my WPF datagrid is specific to each row, because its items need to depend on the DataContext for that row. For example "Save" might be disabled if I know the row has not been edited.
I am looking at the accepted answer for Create contextmenus for datagrid rows and trying to adapt it to the existing xaml I am working with, but I don't know how to use this solution on top of my existing RowStyle.
If I copy and paste the context menu code everything works, but I already have this for RowStyle:
<DataGrid.RowStyle>
<Style TargetType="{x:Type DataGridRow}">
<Style.Triggers>
<Trigger Property="AlternationIndex" Value="1">
<Setter Property="Background" Value="#eed3f7" />
</Trigger>
[...]
</Style.Triggers>
</Style>
</DataGrid.RowStyle>
And I don't understand how to incorporate:
<DataGrid RowStyle="{StaticResource DefaultRowStyle}"/>
Please help!