Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
890 views
in Technique[技术] by (71.8m points)

c# - WPF Application Blurry on High DPI Screen on Windows 10

Do WPF applications normally scale correctly on high DPI screens out of the box (without further customisation of a manifest etc?). It was my understanding they did?

Two WPF applications I have written both appear blurry on my new laptop (running Windows 10) when viewed on the laptop screen. Normally the laptop has it's primary display set to be an external low-dpi monitor and the built-in laptop panel is scaling at 125%. However, the blurriness appears regardless of whether the low-dpi monitor is plugged in or not.

I thought it might have something to do with the way my two applications launch (via a main method, rather than the default code template that launches a primary window), but I've just fired up Visual Studio 2015 and generated a brand new WPF application with the project template (just a couple of radio buttons on a blank form) and it doesn't scale into high DPI on my system either.

It may also be worth mentioning that I have configured the "prefer external manifest" registry setting on my copy of windows to allow per-application disabling of high-dpi scaling with a manifest. (i.e. HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionSideBySide "PreferExternalManifest"=dword:00000001 ).

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Starting with .net 4.6.2 WPF apps are per Monitor DPI aware by default, not in earlier version:

WPF applications are now enabled for per-monitor DPI awareness. This improvement is critical for scenarios where multiple displays of varying DPI level are attached to a single machine. As all or part of a WPF application is transitioned between monitors, the expected behavior is for WPF to automatically match the DPI of the app to the screen. It now does. In previous versions, you would have to write additional native code to enable per-monitor DPI awareness in WPF applications.

So install the .4.6.2 dev tools and target your application to 4.6.2 to get support for this.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...