tsilmer
Topic Author
Posts: 2
Joined: 13 Apr 2021, 01:13

ContextMenu Placement and PlacementTarget intermittently not being respected

29 Sep 2022, 23:54

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:
<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>
this is the ItemTemplate of a TreeViewItem.
 
User avatar
sfernandez
Site Admin
Posts: 2664
Joined: 22 Dec 2011, 19:20

Re: ContextMenu Placement and PlacementTarget intermittently not being respected

30 Sep 2022, 10:38

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.
 
User avatar
sfernandez
Site Admin
Posts: 2664
Joined: 22 Dec 2011, 19:20

Re: ContextMenu Placement and PlacementTarget intermittently not being respected

30 Sep 2022, 10:49

Just an addition, there is no need to explicitly assign the PlacementTarget, it will be automatically set to ContextMenu's owner when opening.
 
tsilmer
Topic Author
Posts: 2
Joined: 13 Apr 2021, 01:13

Re: ContextMenu Placement and PlacementTarget intermittently not being respected

04 Oct 2022, 17:54

Thank you, the issue has been submitted under ticket #2437
 
User avatar
sfernandez
Site Admin
Posts: 2664
Joined: 22 Dec 2011, 19:20

Re: ContextMenu Placement and PlacementTarget intermittently not being respected

11 Oct 2022, 10:32

Thanks for the report, we'll fix it for the next release.

Who is online

Users browsing this forum: Google [Bot] and 1 guest