Hi all,
i want to disable thecontext menu items based on certain condition..
how to disable in window loaded...can any one help me to take the context menu object from the grid and
disable some items
<igDP:Field Name="UserIntID" Label ="" >
<igDP:Field.Settings > <igDP:FieldSettings AllowEdit="False" CellWidth="15" LabelWidth ="15" > <igDP:FieldSettings.CellValuePresenterStyle > <Style TargetType="{x:Type igDP:CellValuePresenter }"> <Setter Property ="Template">
<Setter.Value >
<ControlTemplate TargetType="{x:Type igDP:CellValuePresenter }">
<Image x:Name="img" Source="/Images/GreenStatusLight.png" Tag="{Binding Path=DataItem.UserIntID}" >
<Image.ContextMenu >
<ContextMenu >
<MenuItem Name="Add" Header="Create User" Click
="Add_Click" />
<MenuItem Name="Edit" Tag="{Binding Path=DataItem.UserIntID}" Header="Update User" Click
="Edit_Click"/>
<MenuItem Name="Delete" Tag="{Binding Path=DataItem.UserIntID}" Header="Delete User" Click
="Delete_Click"/>
<MenuItem Name="Seperator" Header="____________" />
</Image.ContextMenu>
</Image>
</ControlTemplate >
</Setter.Value >
</Setter >
</Style>
</igDP:FieldSettings.CellValuePresenterStyle>
</igDP:FieldSettings>
</igDP:Field.Settings>
</igDP:Field ></DataTrigger>
</ControlTemplate.Triggers>
Hello,
I am not sure why you want to disable a context menu in the Window Loaded event when nothing has been rendered yet. You can handle the ContextMenuOpening event of the specific element and suppress the context menu based on that condition. To hookup this event, you can use the EventManager.RegisterClassHandler(...) method or an EventSetter in a style for that element.
Hope this helps.