How to find out horizontal/vertical resolution of screen in WPF

What will be an equivalent of Graphics.DpiX or DpiY in WPF considering that I do not have graphics object as I am using a custom map control hosted on a canvas and rendering graphics using visualCollection and visuals.

Thanks

Atul



Answer this question

How to find out horizontal/vertical resolution of screen in WPF

  • r3n

    Thanks for the reply.

    I am creating an application which needs to convert from device bounds to world coordinates and when somebody zooms or pans we need to do the transfer based on the screen resolution so that we can display the data accurately.

    In earlier version we are using system.drawings which gives us the DpiX or DpiY but I am not sure how to do that in WPF.

    Atul


  • Tigers21

    i dont know exactly but if you want to find screen resolution you could use this:
    SystemParameters.FullPrimaryScreenHeight for screen height
    SystemParameters.FullPrimaryScreenWidth for screen width

    Regards,
    Dat


  • Shariar

    One thing to note is that the input units for positions/sizes/etc in WPF are already DPI independant. The units are 96's of an inch, and we automatically convert that to the appropriate number of device pixels based on the system's DpiX and DpiY. Ideally, this behavior will allow you to ignore the problem entirely.

    If this isn't the case, can you describe more about what you would do if you were able to access DpiX/DpiY so we can help get your scenario working

    Thanks,
    Adam Smith [MS]



  • How to find out horizontal/vertical resolution of screen in WPF