Hi,
I have a XamGrid which has a template column of type Combo Box. The issue is if I select any value on the cell (Combo box value) and right click on it, the context menu opens up which has cut, copy , paste and in which only paste is enabled and cut, copy are disabled. I want to disable this feature i dont want this context menu opening up when I right click on any value in any cell. I have attached the screenshot of the issue.
Thanks
Arpita
Hello Arpita,
Thank you for your post. I have been looking into it and I can suggest you add the following Style for the TextBox in your XamGrid’s Resources in order to disable the ContextMenu since it is the built one of the MS Textbox element:
<Style TargetType="{x:Type TextBox}"> <Setter Property="ContextMenu"> <Setter.Value> <ContextMenu Visibility="Collapsed"/> </Setter.Value> </Setter> </Style
Please let me know if this helps you or you need further assistance on this matter.
Looking forward for your reply.
I don't have any text box element as such in my XamGrid. I have a template column which is of type combo box. This is my xamgrid setting . The setting which u have suggested in your previous post will work in this case?
<ig:XamGrid x:Name="UpdateParameterGrid" Grid.Row="0" MinWidth="600" AutoGenerateColumns="False" Width="Auto" ItemsSource="{Binding AffectedRecipes, Mode=TwoWay}" ScrollViewer.VerticalScrollBarVisibility="Auto" HorizontalAlignment="Center" MaxWidth="1055" HorizontalContentAlignment="Center" FontFamily="Tahoma" FontSize="12" BorderBrush="DarkGray" BorderThickness="0.8" CellControlAttached="UpdateParameterGrid_CellControlAttached" CellEnteringEditMode="UpdateParameterGrid_CellEnteringEditMode" CellExitingEditMode="UpdateParameterGrid_CellExitingEditMode" > <!--CellEnteringEditMode="UpdateParameterGrid_CellEnteringEditMode" CellExitedEditMode="UpdateParameterGrid_CellExitedEditMode" CellExitingEditMode="UpdateParameterGrid_CellExitingEditMode" >--> <ig:XamGrid.CellStyle> <Style TargetType="ig:CellControl"> <Setter Property="BorderThickness" Value="0,0,1,1" /> </Style> </ig:XamGrid.CellStyle> <ig:XamGrid.GroupBySettings> <ig:GroupBySettings AllowGroupByArea="Hidden" GroupByOperation="MergeCells" /> </ig:XamGrid.GroupBySettings> <ig:XamGrid.Columns> <ig:TextColumn Key="Sel_Crit_Inst_Name" HeaderText="Instances" TextWrapping="Wrap" IsReadOnly="True" MinimumWidth="100" /> <ig:TextColumn Key="Sel_Crit_Inst_Id" Visibility="Collapsed" /> <ig:TextColumn Key="Recipe" HeaderText="Recipe" IsReadOnly="True" TextWrapping="Wrap" MinimumWidth="200" /> <ig:TextColumn Key="RecipeKey" Visibility="Collapsed" /> <ig:TextColumn Key="OldParameterValue" HeaderText="Old Value" TextWrapping="Wrap" IsReadOnly="True" MinimumWidth="200"/> <ig:TextColumn Key="OldParamVersion" Visibility="Collapsed" /> <ig:TemplateColumn EditorTemplate="{StaticResource ComboBoxTemplate}" ItemTemplate="{StaticResource ComboBoxTemplate}" HorizontalContentAlignment="Stretch" Key="NewParameterValue" IsReadOnly="False"/> <ig:TextColumn Key="NewParamVersion" Visibility="Collapsed" /> <ig:CheckBoxColumn Key="IsPCGAccesible" Visibility="Collapsed" /> </ig:XamGrid.Columns> <ig:XamGrid.EditingSettings> <ig:EditingSettings AllowEditing="Hover" /> <!--<ig:EditingSettings AllowEditing="Cell" IsOnCellActiveEditingEnabled="True" IsMouseActionEditingEnabled="SingleClick" />--> </ig:XamGrid.EditingSettings> </ig:XamGrid>
I appologize I haven't been clear enough. Since the ComboBox has a TextBox inside its Template, you should create a Style for the Textbox, because the ContextMenu is se t there by default.
I tried your solution but it didn't solve the issue. I included this in my XamGrid Resources section.
<ig:XamGrid.Resources> <Style TargetType="{x:Type TextBox}"> <Setter Property="ContextMenu"> <Setter.Value> <ContextMenu Visibility="Collapsed"/> </Setter.Value> </Setter> </Style> </ig:XamGrid.Resources>
I have been looking into the default Style of the MS ComboBox and since there the Style of the TextBox is set to null it means that a Style is applied by code and this is why the Style I suggested you doesn't apply. I can suggest you handle the ComboBox's GotFocus event and add the following code in its handler:
TextBox tb = Utilities.GetDescendantFromName(sender as DependencyObject, "PART_EditableTextBox") as TextBox; tb.ContextMenu = null;
Hope this helps you.
I actually didn't understand this one.
I have a combo box template defined inside my XamGrid. I already have some events defined for XamGRid. This is my XamGrid definition.
<ig:XamGrid x:Name="UpdateParameterGrid" Grid.Row="0" MinWidth="600" AutoGenerateColumns="False" Width="Auto" ItemsSource="{Binding AffectedRecipes, Mode=TwoWay}" ScrollViewer.VerticalScrollBarVisibility="Auto" HorizontalAlignment="Center" MaxWidth="1055" HorizontalContentAlignment="Center" FontFamily="Tahoma" FontSize="12" BorderBrush="DarkGray" BorderThickness="0.8" CellControlAttached="UpdateParameterGrid_CellControlAttached" CellEnteringEditMode="UpdateParameterGrid_CellEnteringEditMode" CellExitingEditMode="UpdateParameterGrid_CellExitingEditMode" ><!--CellEnteringEditMode="UpdateParameterGrid_CellEnteringEditMode" CellExitedEditMode="UpdateParameterGrid_CellExitedEditMode" CellExitingEditMode="UpdateParameterGrid_CellExitingEditMode" >--><ig:XamGrid.CellStyle><Style TargetType="ig:CellControl"><Setter Property="BorderThickness" Value="0,0,1,1" /></Style></ig:XamGrid.CellStyle><ig:XamGrid.GroupBySettings><ig:GroupBySettings AllowGroupByArea="Hidden" GroupByOperation="MergeCells" /></ig:XamGrid.GroupBySettings><ig:XamGrid.Columns><ig:TextColumn Key="Sel_Crit_Inst_Name" HeaderText="Instances" TextWrapping="Wrap" IsReadOnly="True" MinimumWidth="100" /><ig:TextColumn Key="Sel_Crit_Inst_Id" Visibility="Collapsed" /><ig:TextColumn Key="Recipe" HeaderText="Recipe" IsReadOnly="True" TextWrapping="Wrap" MinimumWidth="200" /><ig:TextColumn Key="RecipeKey" Visibility="Collapsed" /><ig:TextColumn Key="OldParameterValue" HeaderText="Old Value" TextWrapping="Wrap" IsReadOnly="True" MinimumWidth="200"/><ig:TextColumn Key="OldParamVersion" Visibility="Collapsed" /><ig:TemplateColumn EditorTemplate="{StaticResource ComboBoxTemplate}" ItemTemplate="{StaticResource ComboBoxTemplate}" HorizontalContentAlignment="Stretch" Key="NewParameterValue" IsReadOnly="False"/><ig:TextColumn Key="NewParamVersion" Visibility="Collapsed" /><ig:CheckBoxColumn Key="IsPCGAccesible" Visibility="Collapsed" /></ig:XamGrid.Columns><ig:XamGrid.EditingSettings><ig:EditingSettings AllowEditing="Hover" /><!--<ig:EditingSettings AllowEditing="Cell" IsOnCellActiveEditingEnabled="True" IsMouseActionEditingEnabled="SingleClick" />--></ig:XamGrid.EditingSettings></ig:XamGrid>
How can I actually achieve this here? Can you please help how this can be done with my current XamGrid setting.
I am just checking if you got this worked out or you still require any assistance or clarification on the matter.
Since the behavior you have is not a known issue and there is nothing specific in your XamGrid's definition, I am not able to conclude what can cause your behavior and without a sample project I cannot investigate this further for you. If you manage to built and attach such sample I will be happy to assist you further with this.
I will not be able to send the sample project. But I can give you the XamGrid structure which I am using.
Could you please send an isolated sample project, where the issue is reproduced, so I can investigate it further for you?
Thanks I am able to disable it.
I have a question why the context menu opens up in some different place (please refer the image which I have attached in the beginning of the post) when I select some value and right click. The Context menu has cut, copy , paste and in which only paste is enabled and cut, copy are disabled. Why cut and copy are disabled ?
How to solve both of the problems. Can you please help.