Display WPF Popups in Lower Right Corner of Screen using PowerShell

I’ve recently changed my mind on this, but will leave the previous post up in case you want to reposition a WPF popup. If you want a big window to popup in the lower-right corner of the screen, use a WPF Window. WPF Popups are chromeless, it’s true, but they are also limiting in how you can move them around, and how they open and close. ToolTips and BalloonTips are useful, too, but have a character limit and are limiting in other ways.

Here is a super basic lower-right hand corner Window that works no matter how many monitors you have, unlike the popup solution below.

And here is what it looks like:


If you want to use the WPF Popup object

If you don’t want to use a WPF Window and you find yourself limited by notifyicon’s BalloonTips functionality, you can use WPF Popups to display information instead.


This picture is probably inaccurate ;)

Considering the nature of popups, placing them in the lower right should be easy, right? Well, Microsoft’s guide for popup placement was confusing to me, and StackExchange’s top-rated responses weren’t much more straight forward.

So after about twenty minutes of trial and error, I figured out that in order to create a popup in the lower right hand side of the screen, three things are required. First, the Popup’s Placement property must be set to AbsolutePoint. Then, the screen’s working area has to be determined and its values used to update the popup’s VerticalOffset and HorizontalOffset. This is similar to winform’s location property.

The following code will create a popup in the lower right hand corner if you have a single monitor. I don’t have a consistent solution for multiple monitors and Popups. Note that it will not create a notifyicon. That will be covered in my next post.

And here is what it looks like:


This code will work for any sized popup. Also, this form’s Window and Popup objects were stripped down to only the required properties. If you remove any of them, it won’t work as demonstrated.

I’m not a GUI pro, but my understanding of this is that an invisible form hosts a popup. You can’t see the form, and only the popup is visible. While StaysOpen=”False” usually allows the popup to close on LostFocus, it doesn’t work that way in this form. If StaysOpen is left out, the popup will never respond to the $form’s MouseDoubleClick event. You’ll just hear a ding when clicking the popup to close it. I’m assuming that’s Windows’ way of saying the action is forbidden.

Chrissy is a Cloud and Datacenter Management & Data Platform MVP who has worked in IT for over 20 years. She is the creator of the popular SQL PowerShell module dbatools, holds a master's degree in Systems Engineering and is coauthor of Learn dbatools in a Month of Lunches. Chrissy is certified in SQL Server, Linux, SharePoint and network security. You can follow her on Twitter at @cl.

Posted in PowerShell, WPF
One comment on “Display WPF Popups in Lower Right Corner of Screen using PowerShell
  1. Gael says:

    Nice post!
    I had to do something similar a while back with PowerShell and I used WPF-notifyIcon.
    It’s a c# lib on codeproject, very convenient with plenty of examples, but you probably know already!

Leave a Reply

Your email address will not be published. Required fields are marked *