I am working on Xamdatagrid with WPF MVVM pattern. I am displaying context menu on right click event on row of grid. Could we restrict the Context menu visibility on some row depending on certain condition. e.g. If I right clicked on a one row it should display context menu and if I right clicked on second row it should not.
Here is the code
<ContextMenu x:Key="RecordContextMenu" Visibility="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type igDP:XamDataGrid}}, Path=DataContext.ContextMenuVisibility, Converter={StaticResource BoolVisibilityConverter},Mode=TwoWay}"> <ContextMenu.Resources> <Converters:BoolVisibilityConverter x:Key="BoolVisibilityConverter" /> </ContextMenu.Resources> <MenuItem Name="SendTo" Header="Send To" Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type igDP:XamDataGrid}}, Path=DataContext.SendCommand}" CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type igDP:XamDataGrid}},Path=ActiveRecord}"> </MenuItem> </ContextMenu> <Style TargetType="{x:Type igDP:DataRecordCellArea}"> <Setter Property="ContextMenu" Value="{DynamicResource RecordContextMenu}"></Setter> </Style> </igDP:XamDataGrid.Resources>
Hello,
I am just checking if my last reply was helpful for you.
If you require any further assistance please do not hesitate to ask.
Sincerely,
Krasimir
Developer Support Engineer
Infragistics, Inc.
www.infragistics.com/support
You can add an EventSetter for the ContextMenuOpening and in its event handler you can decide whether or not to open the ContextMenu.
Infragistics