PopupButton: Popup/ContextMenu placement

WPF Studio, Themes, and Shared Library for WPF Forum

Posted 8 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 8 years ago]

Comments (4)

Posted 8 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 8 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 8 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 8 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 8 years ago]

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

Add Comment

Please log in to a validated account to post comments.