I am using a WPF Popup control. I want it to appear inside my application window, anchored in the bottom right corner of the window. The actual height and Width of the popup will change depending on the message that is being displayed.
If it matters, the content of the popup are a Border, wrapping a StackPanel, holding multiple TextBlocks.
Thank you for any help.
Use PlacementTarget, Placement=Left, Horizontal/VerticalOffset
<Popup IsOpen="{Binding ElementName=togglebutton, Path=IsChecked, Mode=TwoWay}"
PlacementTarget="{Binding ElementName=togglebutton}"
Placement="Left"
HorizontalOffset="{Binding ActualWidth, ElementName=togglebutton}"
VerticalOffset="{Binding ActualHeight, ElementName=togglebutton}">
I just did something like this, and it's really not that tricky, but it does require custom placement of your popup. When you declare your popup just set the PlacementMode property to Custom, then set the CustomPopupPlacementCallback property to the method you want to use.
this.trayPopup.CustomPopupPlacementCallback = GetPopupPlacement;
private static CustomPopupPlacement[] GetPopupPlacement(Size popupSize, Size targetSize, Point offset)
{
var point = SystemParameters.WorkArea.BottomRight;
point.Y = point.Y - popupSize.Height;
return new[] { new CustomPopupPlacement(point, PopupPrimaryAxis.Horizontal) };
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With