Search code examples
c#wpfwindowsdpi-aware

Does WPF Per Monitor DPI awareness really work by default?


Recently I started looking into Per Monitor DPI awareness for windows 10 and noticed that it should be supported by default as I'm using .net5.0 if there are a couple of things configured.

So I went along and followed the steps from this article: https://github.com/Microsoft/WPF-Samples/tree/master/PerMonitorDPI

And nothing happened on for the main app I've tried it.

Then I've decided to create a small sample app with a button and some text, thinking that perhaps the styling and custom stuff in the main app block something, and behold, when switching the sample app's window to my secondary monitor, the text is blurry.

Looking into the samples provided I see that there are a bunch of refresh stuff done in code behind when DPI changes, this looks a lot like "before per monitor DPI aware work-around code".

Can someone help me? What am I missing, i understood that WPF supports this out of the box on windows 10, do I still need those hundreds of lines of code to refresh everything when changing monitors?


Solution

  • As @emoacht has commented, using "PerMonitorV2" instead of just "PerMonitor" makes WPF applications automatically Per monitor DPI aware for Windows 10 (after a certain build number)

    In case you have converted your application from an older .Net version and just changed the project to SDK Style, don't forget to mention the manifest in the project file.

    enter image description here