I've been linked in the past to this response to a similar question on converting WPF pixel coordinates to desktop ones, however I'm not sure I understand the maths involved.
Astonish' answer states that "Pixels per WPF Unit = ConstantWPFUnit size * monitor DPI;" and that "The constant WPF unit size is 1/96."
In my case, I've taken the DPI from a graphics object which was created from the bitmap object (as I couldn't find the property the Astonish spoke of) that I created after taking a screenshot of the desktop, so I have:
Graphics g = Graphics.FromImage(bitmap);
float WpfUnit = (1 / 96) * g.DpiX;
Given that the DPI being returned from the graphics object is 96, I am left with
WpfUnit = (1 / 96) * 96 = 1
However, WpfUnit is coming out as 0 for some unknown (to me) reason. The only way I can see to fix this is to say
if(WpfUnit == 0) WpfUnit = 1;
And even that doesn't really fix the issue, as the height value and top values, when multiplied by the WpfUnit as suggested in the linked answer, have nothing done to them aside from being multiplied by 1.
So, in conclusion, I'm still stuck on converting WPF pixels to desktop pixels. Any help on this would be greatly appreciated.
Regards, Andy Hunt