问题描述
我对 WPF 中的每显示器 dpi 感知有点困惑.我认为您需要做一些工作才能使您的窗口在不同的显示器上正确缩放(如 开发每监视器 DPI 感知 WPF 应用程序).
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).
但我刚刚在带有两台显示器(2560x1440 和 2160x1440)的 PC 上运行了我的应用程序,当我在显示器之间移动时,对话会自动缩放.这是最新的快速环 Windows 10.我错过了什么吗?
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?
推荐答案
当一个应用程序窗口移动到具有不同 DPI 的不同显示器时,您看到的是系统缩放示例.这是因为 WPF 应用程序默认为系统 DPI 感知.因此,如果您仔细观察,您会看到当目标 DPI 较高时 WPF 视觉效果/文本变得模糊,或者当目标 DPI 较低时它们看起来很模糊.另请注意,WPF 应用程序的显示器分辨率无关紧要,因为 WPF 与设备分辨率无关(它的测量单位是设备独立像素).
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).
好消息:.NET 4.6.2 预览版刚刚发布,它具有开箱即用的 Per Monitor DPI Awareness.在此处查看开发者指南和示例:
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
这篇关于我的 WPF 应用程序是开箱即用的每个显示器 dpi 感知.我没想到?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!