views:

158

answers:

1

Hey

I'm currently using a semi-transparent WPF form with no border as a camera style device in a program of mine. However, when I access the position (top, left) and dimension (height, width) properties of the form, it would appear they are wrong.

The top property reported to be roughly 26 pixels higher than it actually is in relation to the desktop. IE if I put the forms top and left at (0,0) the properties will report (0, -26).

The height is also incorrect, reporting about 50-60 pixels shorter than it actually is.

Has anybody experienced this problem in the past and have a solution?

Regards, Andy Hunt

A: 

Hi,

if I understand correctly, this is no problem at all but the expected behavior. WPF uses DPI-independent virtual units for measuring size and position, not actual pixels.

There are many sources like this explaining this.

If I understood the question wrong (its late and I am tired ;) could you provide a code sample illustrating the issue?

Andrej

Andrej
Ah, well it would appear my problem is with converting the position reported by the WPF form in to the pixel co-ordinates in relation to the desktop then. Do you know of any solution for this?
You can convert WPF Units to pixels and vice versa quite easy, have a look at this:http://stackoverflow.com/questions/611427/wpf-canvas-height-in-pixels
Andrej
Thanks a lot! That worked just fine :)