I\'m trying to display a popup under a button.
This is what it looks like now :
I fixed it by setting the placement the custom:
<views:OptionPopup x:Name="OptionsMenuPopup"
PlacementTarget="{Binding ElementName=AdminPanel}"
Placement="Custom"
MinWidth="{Binding ActualWidth, ElementName=AdminPanel}"
MaxWidth="{Binding ActualWidth, ElementName=AdminContainer}" />
And in the constructor of my usercontrol in code behind I added
OptionsMenuPopup.CustomPopupPlacementCallback += (Size popupSize, Size targetSize, Point offset) =>
new[] { new CustomPopupPlacement() { Point = new Point(targetSize.Width - popupSize.Width, targetSize.Height) } };
You could use a combination of SystemParameters.PrimaryScreenHeight and the top-left point of the Popup to calculate how much room you have, and set that as the MaxHeight and MaxWidth of the Popup's contents.