Hi,
I have redefined a context menu for my grid's elements like this :
XAML<dxg:TableView.ContextMenu>
<ContextMenu Visibility="{Binding CurrentMessage,Converter={StaticResource NullToVisibilityConverter}, ConverterParameter=1}">
<MenuItem Header="Répondre" Command="{Binding AnswerCommand}" CommandParameter="ANSWER"/>
<MenuItem Header="Répondre à tous" Command="{Binding AnswerCommand}" CommandParameter="ANSWER_TO_ALL"/>
<MenuItem Header="Transférer" Command="{Binding AnswerCommand}" CommandParameter="TRANSFER"/>
<Separator/>
<MenuItem Header="Supprimer" Command="{Binding DeleteMailCommand}" CommandParameter="ANSWER"/>
<MenuItem Header="Marquer comme non lu" Command="{Binding MarkAsUnreadCommand}"/>
<Separator/>
<MenuItem Header="Enregistrer la pièce jointe" Visibility="{Binding CurrentMessage.HasAttachment, Converter={StaticResource BooleanToVisibilityConverter}, ConverterParameter=1}">
<MenuItem Header="Dans le dossier patient" Command="{Binding SaveAttachmentCommand}" CommandParameter="True"/>
<MenuItem Header="Enregistrer sous ..." Command="{Binding SaveAttachmentCommand}" CommandParameter="False"/>
</MenuItem>
<MenuItem Header="Enregistrer le mail" Command="{Binding SaveMailCommand}"/>
<!--<Separator/>-->
<!--<MenuItem Header="Imprimer" Command="{Binding PrintCommand}"/>-->
</ContextMenu>
</dxg:TableView.ContextMenu>
It works great. BUt, I don't want this menu to be displayed on group rows (this is why Visibility of menu is set to the currentMessage, which is the currentItem, and NullToVisibilityConverter prevents menu to appear if no message selected).
If I right click on group row, nothing shows up, which is want I want. But when I select a message by left-clicking on it, the contextMenu shows up (passing throught converter).
Is there a simple and effective way to prevents showing my custom context menu on group rows ?
Thanks
Hi Christophe,
Your scenario is not entirely clear to me. Should custom menu items be shown only for data rows, but not for an "empty" area or other grid elements? If so, I suggest that you use the TableView.RowCellMenuCustomizations property instead of TableView.ContextMenu.
Hi Alexander,
It seems great, but we have created a whole style for application context menu to look like other one, so using rowCellMenu may broke our style-line.
Is there another way to achiveve my goal ?
Thanks
Hello Christophe,
In this case, I suggest you handle the TableView.ContextMenuOpening event and call the TableView.CalcHitInfo(Point) method to get information about an element in GridControl that is clicked. Set the ContextMenuEventArgs.Handled property to True if the GridViewHitInfoBase.InRow property is True and the result of GridControl's method with the GridViewHitInfoBase.RowHandle property value as a parameter returns False.
I've created a simple sample to illustrate the main idea of the approach. Is it suitable for you?
Thanks,
Andrey
Hi Andrey,
Yes, exactly. Thank you.
I'm happy to hear that my assistance was helpful. I've posted an answer with a short description of the main idea of the approach to allow other customers that might have the same requirements to find this information more easily.
Please do not hesitate to contact us if you have any further questions.
Andrey