My WPF app is per-monitor dpi-aware out of the box. I was not expecting that?

ぐ巨炮叔叔 提交于 2020-01-12 18:53:08

问题


I am a bit confused about per-monitor dpi-aware in WPF. I thought you need to do some work to make your windows scale properly on different monitors (as described in Developing a Per-Monitor DPI-Aware WPF Application).

But I've just ran my app on pc with two monitors (2560x1440 and 2160x1440) and the dialogue would automatically scale itself when I move it between monitors. That's on the latest fast ring Windows 10. Am I missing something?


回答1:


What you see is an example of System scaling when one app window moves to a different monitor with a different DPI. That is because WPF apps are by-default System DPI Aware. As a result, if you notice carefully, you'll see WPF visuals/text gets blurred when the target DPI is higher or they look fuzzy when the target DPI is lower. Also, note that monitor resolution does not matter for WPF apps, since WPF is device resolution agnostic (it's measurement unit is Device independent Pixels).

Good news : .NET 4.6.2 preview just got released and it hasPer Monitor DPI Awareness out of the box. Check out the developer guide and samples here :

https://github.com/Microsoft/WPF-Samples/tree/master/PerMonitorDPI




回答2:


Continuing the conversation from comments.
Yes that is the same for Windows 8.1.
And here is the note from your linked post

Windows Presentation Foundation (WPF) applications are by default system DPI-aware.

HTH



来源:https://stackoverflow.com/questions/35865238/my-wpf-app-is-per-monitor-dpi-aware-out-of-the-box-i-was-not-expecting-that

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!