Apparently there is a ContextMenu (Cut/Copy/Paste) in the cells of xamdatapresenter. How can i turn it off but keep my custom ContextMenu i created for the grid itself? As an example, see the Feature Browser WPF->xamDataGrid->Data Binding and Interaction->Unbound Fields. When you select the text inside of a cell, you can then right click and you will see a contextMenu w/ Cut/Copy/Paste.
Also, why don't the doesn' Ctrl-X, C or V actually perform the cut copy or paste anyway. Can i remove just the inputGestureText from the menu since it doesn't work anyway?
Hello,
If you add only this keyless Style:
<Style TargetType="{x:Type igEditors:XamTextEditor}"> <Setter Property="ContextMenu"> <Setter.Value> <ContextMenu Visibility="Collapsed"/> </Setter.Value> </Setter> </Style>
It will remove the contextmenus from all the Fields, Bound and Unbound.
Hope this helps you.
Looking at this again, there is still a context menu for the unbound field. Your solution worked for the other fields, but the keyed style you applied to the unbound field doesn't seem to be working, as the default ContextMenu still appears when i select text in the unbound field ????
Since I can't set AllowEdit=False for the unbound field because it will depend on my DataItem.Loc property, I must use IsReadOnly on the xamTextEditor. How can I apply what you've shown me to set Visibility to collapsed when IsReadOnly is true, but Visible when IsReadOnly is false? I tried <Setter Property="ContextMenu.Visibility" Value = "Collapsed" but that seems to just hide the field contents instead. That way I could a context menu that simply shows Cut/Copy/Paste (without shortcuts) and not have it visible when the user isn't supposed to be editing it anyway. Or should i just make two different context menus, one set to collapsed and the other with my cut/copy/paste (with no shortcuts)?
Apparently since AllowEdit cannot be false, IsInEditMode can be true even though IsReadOnly is true, which seems to be the root of my problem since unbound fields that I do have set to AllowEdit=True obviously don't have the context menu problem anyway.
<igDP:UnboundField Name="Place" Label="Place" BindingPath="Place" BindingMode="TwoWay" Column="2" Row="0" Converter="{StaticResource ValueConverter}"> <igDP:Field.Settings> <igDP:FieldSettings CellMinWidth="150"> <igDP:FieldSettings.EditorStyle> <Style TargetType="{x:Type igEditors:XamTextEditor}"> <Style.Triggers> <DataTrigger Binding="{Binding Path=DataItem.LatLon_IsReadOnly}" Value="True"> <Setter Property="IsReadOnly" Value="True"/> <Setter Property="ContextMenu" Value="{StaticResource NoContextMenu}"/> </DataTrigger> <!--<Trigger Property="IsInEditMode" Value="True"> <Setter Property="ContextMenu" Value="{StaticResource NoContextMenu}"/> </Trigger>--> </Style.Triggers> </Style> </igDP:FieldSettings.EditorStyle> </igDP:FieldSettings> </igDP:Field.Settings> </igDP:UnboundField>
Since the ContextMenu is set to the TextBox element in the Editor via code, not using Style, it is expected that setting the XamTextEditor's ContextMenu Property to x:Null in Style won’t hide it.
what is the reasoning for not simply being able to set ContextMenu="{x:Null}" instead of making a collapsed context menu? this works on regular text boxes, but apparently not on the IG xamTextEditor?
I have modified the sample you sent us, so now it has the functionality you want. Basically I created a keyless Style for the XamTextEditor for the bound Fields, where I set the Visibility of the ContextMenu to Collapsed. Also I created a Style with Key and set it to the UnboundField’s Settings’ EditorStyle Property.