I have a wpf application that is designed for a 1900x1200 resolution but some of our users have used the windows display settings to resize everything by 125%-150%, is there a way to have an application ignore those settings and still display normally?
I have seen something called SetProcessDPIAware here, but havent had any luck with it.
Here is a screen shot of the application with the display scaling turned up to 150%
As you can see the application is way too small and there is no way to get it to be correctly sized.
Dpi awareness will not help in this case. It will only change CompositionTarget.TransformToDevice matrix, but controls sizes will not change.
I use view box to scale all content. All sizes in my app are designed for Surface Pro 3 portrait:
<Window>
<Viewbox Stretch="Uniform">
<Grid Width="1440" Height="2160">
<!-- ... -->
</Grid>
</Viewbox>
</Window>
You can calculate view box size basing on screen DPI. See this answer: https://stackoverflow.com/a/12414433/991267
New way to ignore dpi is:
Right click on your project
Add > New item
Find "Application Manifest File (Windows Only)
Uncomment at line 55, or find dpiAware
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
<longPathAware xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">true</longPathAware>
</windowsSettings>
</application>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With