I'm trying to create a ComboBox
with a non-standard dropdown alignment. Basically, I want the dropdown to be below the ComboBox
, but aligned with the right edge of the ComboBox
instead of the left edge.
What a normal ComboBox
looks like, using PlacementMode="Bottom"
:
What I want:
I tried to play with the Popup.PlacementMode
property in the template of my ComboBox
, but none of the possible values seem to do what I want. Is there a simple way to do it, preferably in pure XAML?
When I opened Expression Blend, I have come up with the solution within a few seconds:
Sometimes this application is more useful than writing xaml by hands, but not so often.
Can someone post the complete xaml code please?
I've tried the following:
... after some working and testing I've found a good solution...
I would use the "Custom" placementmode for the PopUp and declare a callback to place the popup control into the correct position, like it's shown here: WPF ComboBox DropDown Placement
See if an example here would work for you:
hope this helps, regards
it's a little hacky, but does work. you just have to change the combobox style.
The popups HorizontalOffset just has to get the value of PopupContent.ActualWidth-PlacementTarget.ActualWidth. To get that value I used this trick from Charles Petzold.