I was playing around creating a notification window just like the one of MSN with WPF and I found a problem. In order the place the window in the Bottom, Right corner of the screen I tried to do the following
The window was not showing up on screen and I got confused. After some thinking I realized that the problem was that WPF uses DPI while the other measurement was in Pixels. In order to set the correct location we must convert the Screen.Primary.WorkingArea.Width and Height which is in Pixels to DPI. The question is HOW?
I found a good post on the forums that helped me a lot here. In order to convert the Screen.Primary.WorkingArea.Width and Height and fix the Top and Left of the window to be the Bottom, Right corner we have to do the following
one of the questions you might be asking yourself would be;
Why is he doing it in the Loaded Event of the Window?
Basically PresentationSource.FromVisual will return null if the Window is not shown yet.
I hope this helps ….