ContextMenu Placement and PlacementTarget intermittently not being respected
Hello,
We are running into a weird intermittent issue with the placement of ContextMenus. Sometimes when we open our app, the ContextMenuService.PlacementTarget and ContextMenuService.Placement properties that we set in a element is not respected and the ContextMenu is instead always placed at the mouse cursor position. The issue is intermittent though, so sometimes it works as expected and sometimes it does not, it only happens when we open the app, if we open the app and it works once then it always works and vice versa.
I tried to reproduce this in one of the Noesis samples but I couldn't, it always worked as expected when I isolate everything. I'm suspecting this could be a bug with Noesis when interacting with some other elements, just like the case we saw the other day with the TreeView. So maybe you guys could ask some questions about things that I could test to help us narrow down the issue, and figure it out if this is a bug or just a mistake on our side.
The setup we have is something like this:
this is the ItemTemplate of a TreeViewItem.
We are running into a weird intermittent issue with the placement of ContextMenus. Sometimes when we open our app, the ContextMenuService.PlacementTarget and ContextMenuService.Placement properties that we set in a element is not respected and the ContextMenu is instead always placed at the mouse cursor position. The issue is intermittent though, so sometimes it works as expected and sometimes it does not, it only happens when we open the app, if we open the app and it works once then it always works and vice versa.
I tried to reproduce this in one of the Noesis samples but I couldn't, it always worked as expected when I isolate everything. I'm suspecting this could be a bug with Noesis when interacting with some other elements, just like the case we saw the other day with the TreeView. So maybe you guys could ask some questions about things that I could test to help us narrow down the issue, and figure it out if this is a bug or just a mistake on our side.
The setup we have is something like this:
Code: Select all
<DataTemplate x:Key="TreeViewComponentStyle">
<Border x:Name="OuterBorder" ContextMenuService.Placement="Left" ContextMenuService.PlacementTarget="{Binding ElementName=OuterBorder}">
<Border.ContextMenu>
<ContextMenu Name="MyContextMenu">
<MenuItem Header="Test" />
</ContextMenu>
</Border.ContextMenu>
<b:Interaction.Triggers>
<noesis:GamepadTrigger Button="Accept" FiredOn="ButtonDown">
<b:ChangePropertyAction TargetName="MyContextMenu" PropertyName="IsOpen" Value="True" />
<b:Interaction.Behaviors>
<b:ConditionBehavior>
<b:ConditionalExpression ForwardChaining="And">
<b:ComparisonCondition LeftOperand="{Binding Path=DataContext.SOMETHING, ElementName=MainWindow}" Operator="Equal" RightOperand="{x:Static model:VALUE_FROM_OUR_VIEW_MODEL}" />
<b:ComparisonCondition LeftOperand="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type TreeViewItem}}, Path=IsSelected}" Operator="Equal" RightOperand="True" />
</b:ConditionalExpression>
</b:ConditionBehavior>
</b:Interaction.Behaviors>
</noesis:GamepadTrigger>
</b:Interaction.Triggers>
</Border>
</DataTemplate>
-
sfernandez
Site Admin
- Posts: 3008
- Joined:
Re: ContextMenu Placement and PlacementTarget intermittently not being respected
Hi, this is a bug for sure, because it should behave always the same. Without reproducing it yet my guess is that sometimes the ContextMenu property is processed before the other context menu related properties in the Border element, and the context menu falls back to the default value. If you can please open a ticket in our bugtracker indicating which version of NoesisGUI you are using I could prepare a patch for you to test.
Sorry for the inconvinience.
Sorry for the inconvinience.
-
sfernandez
Site Admin
- Posts: 3008
- Joined:
Re: ContextMenu Placement and PlacementTarget intermittently not being respected
Just an addition, there is no need to explicitly assign the PlacementTarget, it will be automatically set to ContextMenu's owner when opening.
Re: ContextMenu Placement and PlacementTarget intermittently not being respected
Thank you, the issue has been submitted under ticket #2437
-
sfernandez
Site Admin
- Posts: 3008
- Joined:
Re: ContextMenu Placement and PlacementTarget intermittently not being respected
Thanks for the report, we'll fix it for the next release.
Who is online
Users browsing this forum: Bing [Bot], Google [Bot] and 4 guests