Hi,
My problem is that I'm losing the context menu on a xamdatagrid after a series of steps. I have a xamdatagrid and do this:
1. Select a bunch of rows.
2. Right click anywhere on the selected rows.
3. Context menu pops up as expected.
4. Left click on one of the selected row.
5. Selection of the bunch of rows remains.
6. Right click again anywhere on the selected rows.
7. Context menu DOES NOT pop up and xamDataGrid_PreviewMouseRightButtonDown DOES NOT get called
Any ideas?
Thanks!
Hello, L A,
Thank you for providing feedback.
I’m glad that you have resolved your issue.
If you have more questions, don’t hesitate to ask.
Sincerely,
Svetla
Thank you. The sample worked and illustrated a few basic things - I was able to start from there vs my code and to eliminate parts until I got my fix
The problem was that I actually had another event, xamDataGrid_PreviewMouseMove which would perform a drag and drop but the object had some issues so that didn't correctly clear the multiple selection in the grid.
It's good now. Thanks again!
Hello L A,
I’ve been looking into your code and I can’t reproduce the issue.
I’ve created a small isolated sample with PreviewMouseRightButtonDown event for reference and the event is fired every time.
In order further to investigate this issue, can you provide a runnable sample and more information about the version of the product you are using?
Looking forward for your reply.
Hi, thanks for the reply.
Here a sample of my grid code:
<igDP:XamDataGrid.Resources> <dp:ProductBoldingConverter x:Key="productBoldingConverter"/> <dp:TextColorConverter x:Key="textColorConverter"/> <!-- Apply a style to every row --> <Style TargetType="{x:Type igDP:DataRecordPresenter}"> <!-- Catch a mouse right click to show the context menu --> <EventSetter Event="PreviewMouseRightButtonDown" Handler="xamDataGrid_PreviewMouseRightButtonDown"/> <Setter Property="FontWeight" Value="{Binding DataItem, Converter={StaticResource productBoldingConverter}}"/> </Style> <Style TargetType="{x:Type igDP:GroupByRecordPresenter}"> <!-- Catch a mouse right click to show the context menu on the group by header --> <EventSetter Event="ContextMenuOpening" Handler="xamDataGrid_ContextMenuOpening"/> </Style> <!--<Style TargetType="{x:Type igDP:LabelPresenter}"> <EventSetter Event="ContextMenuOpening" Handler="xamDataGrid_ContextMenuOpening"/> </Style>--> <Style TargetType="{x:Type igDP:DataRecordCellArea}" BasedOn="{x:Static igThemes:DataPresenterAero.DataRecordCellArea}"> <Setter Property="Foreground" Value="{Binding DataItem, Converter={StaticResource textColorConverter}}"/> <Setter Property="BackgroundAlternate" Value="#06000000"/> <Style.Triggers> <MultiDataTrigger> <MultiDataTrigger.Conditions> <Condition Binding="{Binding RelativeSource={RelativeSource Mode=Self}, Path=IsSelected}" Value="True" /> <Condition Binding="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type dpMP:GenericGrid}}, Path=CustomSelectedStyle}" Value="True" /> </MultiDataTrigger.Conditions> <Setter Property="FontWeight" Value="Bold" /> </MultiDataTrigger> </Style.Triggers> </Style> <Style TargetType="{x:Type igDP:CellValuePresenter}"> <Setter Property="ToolTip" Value="{Binding RelativeSource={RelativeSource Self}, Path=Value, Converter={StaticResource ResourceKey=ToolTipConverter}}"/> <EventSetter Event="ToolTipOpening" Handler="xamDataGrid_ToolTipOpening"/> <EventSetter Event="PreviewMouseLeftButtonDown" Handler="xamDataGrid_PreviewMouseLeftButtonDown"/> <EventSetter Event="PreviewMouseLeftButtonUp" Handler="xamDataGrid_PreviewMouseLeftButtonUp"/> </Style> </igDP:XamDataGrid.Resources> <igDP:XamDataGrid.FieldLayoutSettings> <igDP:FieldLayoutSettings RecordSelectorLocation="None" AllowDelete="False" AutoGenerateFields="False" SelectionTypeRecord="Extended" HighlightAlternateRecords="True"/> </igDP:XamDataGrid.FieldLayoutSettings> <igDP:XamDataGrid.FieldSettings> <igDP:FieldSettings AllowRecordFiltering="False" CellClickAction="SelectRecord" AllowEdit="False"/> </igDP:XamDataGrid.FieldSettings> </igDP:XamDataGrid>
Inside the PreviewMouseRightButtonDown event I build and show the context menu depending on what rows are selected.
The problem is that PreviewMouseRightButtonDown does not get called at all times. What I'm trying to figure out is why not.
To me, it looks like the PreviewMouseRightButtonDown should be called at all times when I right click on the grid because it is as an eventSetter under igDP:DataRecordPresenter.
When I have a multiple selection, left click once on a row, then right click again on my multiple selection what exactly am I clicking on? I assume it's a igDP:DataRecordPresenter so the PreviewMouseRightButtonDown should fire but it won't.
Thanks.
Thank you for your post.
In order further to investigate your issue, can you provide a sample and more information about the version of the product you are using?