Ribbon ContextMenu has wrong placement

Ribbon for WPF Forum

Posted 14 years ago by Chris Chenery
Version: 9.1.0500
Avatar
I'm using the ribbon ContextMenu with a wpf TreeView control and the menu popup is being displayed at the top left corner of the screen rather than where the mouse cursor is located.

I'm creating the ContextMenu in the TreeView's ContextMenuOpening event handler, with the event's original source being a treeviewitem. The ContextMenuClosing event also isn't being fired.

Both the menu placement and the ContextMenuClosing event are correct when using the standard Wpf ContextMenu control.

Am I just missing something obvious when creating the contextmenu or is this a bug?

Cheers

Comments (2)

Posted 14 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Chris,

Our ribbon context menu inherits the standard WPF ContextMenu so I would think the behavior would be the same. If not, then please make a simple sample project that shows the issue and email it over so we can have a look. Thanks!


Actipro Software Support

Posted 14 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Chris,

Thank you for the sample. It looks like the Ribbon ContextMenu was setting the placement to Bottom by default, so it would not display correct the first time. We've updated the Ribbon ContextMenu so it doesn't change the default value of the Placement property. In the meantime, you could set Placement explicitly to MousePoint.

Based on your sample, both the native WPF ContextMenu and the Ribbon ContextMenu (which inheirts from the native WPF ContextMenu) will not call the ContextMenuClosing event the first time they are displayed. The problem here is that the first time the context menu is being displayed, you are explicitly setting the ContextMenu property and opening the context menu. The subsequent times, the ContextMenu is set and is managed completely by WPF.

To fix this latter issue, you could explicitly set the ContextMenu property to an empty Ribbon ContextMenu (either via an implicit Style or explicity). Then in the ContextMenuOpening event, you would simply add items to the ContextMenu but not open it (and let WPF handle that).

Hope this helps.


Actipro Software Support

The latest build of this product (v24.1.1) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.