Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Force DPI for testing in WPF

Tags:

dpi

wpf

Is there any way to trick a WPF application into thinking that it is running at a certain DPI?

I'd like to test my program at various DPI levels (96, 120, 144, 192) without changing the system setting (which requires a log-out/in under Windows 7).

Can I manually set the size of 1 DIU? (At 96 DPI, 1 DIU = 1 pixel. I'd like to set 1 DIU to 1.25 pixels to imitate 120 DPI.)

like image 919
Quppa Avatar asked Mar 06 '11 02:03

Quppa


1 Answers

You might be able to do what you want if you ScaleTransform the outtermost container. You'd just need to calculate the different between the current dpi and the target dpi and set the scale accordingly.

The other option is to use something like http://research.microsoft.com/en-us/projects/detours/ to override the windows API methods that gives the device dpi. I doubt you would want to go there though.

like image 164
Steven Avatar answered Oct 05 '22 20:10

Steven