PopupButton: Popup/ContextMenu placement

WPF Studio, Themes, and Shared Library for WPF Forum

Posted 9 years ago by Markus Springweiler
Version: 16.1.0631
Avatar

Is there any (attached) property which controls the placement of the popup/contextmenu? I have a 1000px wide PopupButton and a 100px wide ContextMenu so the mouse pointer has to travel 900px to reach the ContextMenu after having pressed the dropdown glyph. Binding the PopupHorizontalOffset to ActualWidth does not really make it looking better.

[Modified 9 years ago]

Comments (4)

Posted 9 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Markus,

We just set the menu's PlacementTarget = popupButton and the Placement = Bottom.  You could probably set properties like PlacementRect or CustomPopupPlacementCallback on your ContextMenu though to see if those help.


Actipro Software Support

Posted 9 years ago by Markus Springweiler
Avatar

Ahh, I did not even think to look at the content... but if I use PopContent instead of a ContextMenu? Who then controls the placement? (And non of the Placement enum values seem to target the scenario "align right edges")

Posted 9 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Markus,

For popups, I believe PlacementTarget and Placement are still explicitly set.  But you have access to PopupHorizontalOffset and PopupVerticalOffset properties you can set on the PopupButton itself to adjust things.


Actipro Software Support

Posted 9 years ago by Markus Springweiler
Avatar

For the PopupContextMenu I solved it by first doing the totally opposite -- setting ContextMenu.Placement=Left (by Loaded-event because XAML definition gets nuked=overridden at runtime) -- and then relative-self-bind PopupHorizontalOffset and PopupVerticalOffset to the ActualWidth/-Height of the according PopupButton.

[Modified 9 years ago]

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

Add Comment

Please log in to a validated account to post comments.