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
1: Left = Screen.PrimaryScreen.WorkingArea.Width - this.Width
2: Top = Screen.PrimaryScreen.WorkingArea.Height - this.Height
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
1: Loaded +=
4: PresentationSource source = PresentationSource.FromVisual(this);
6: if (source != null)
8: Left = (Screen.PrimaryScreen.WorkingArea.Width * source.CompositionTarget.TransformFromDevice.M11) - Width;
9: Top = (Screen.PrimaryScreen.WorkingArea.Height * source.CompositionTarget.TransformFromDevice.M11) - Height;
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 ….
Let me start by saying that I am NOT a ClickOnce expert, yet today I encountered a problem and thought of sharing with you guys my experience. So I was deploying a ClickOnce installer on a server and when I clicked “Publish Now”, I got an error saying “….The Web server does not appear to have FrontPage Server Extensions installed……”.
The first thing I tried was to change the “Publish Folder Location” to my local IIS (localhost) which worked fine on my machine, yet when I tried the ClickOnce installer on another machine it did not work because setup.exe was trying to connect to my machine to download the *.application file. After some research I found out that you can publish the ClickOnce to a location and instruct it to do download from another location. In order to do this you have to put the URL of the live server in the “Installation Folder URL” textbox which is located below the “Publishing Folder Location” textbox (as shown in the image below).
To summarize you can put in 2 different URL, where to Publish the ClickOnce and where the ClickOnce will be actually downloaded from. In my case I set the “Publishing Folder Location” to the localhost (that had IIS) and set the “Installation Folder URL” to the actual server URL (the one that the clients would be using to download the actual installer). Then once I am happy I just upload the files from the localhost to the actual live server, and everything just works 🙂
Hope this helps….