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

2

13

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?

Ianthe answered 8/3, 2016 at 10:44 Comment(4)
As long as you don't hard code values in you UI elements WPF app will scale it self automatically.Reform
@Reform is that true for Windows 8.1 as well? and what about that article that I've linked in the post? It does say that you have to listen the dpi changed event yourself.Ianthe
Unrelated, but now I'm curious; what happens if your window is halfway between both monitors?Worship
@BTownTKD Your Top Left position of the window is the start point so if you have a MessageBox it would appear on the monitor that has the Windows's Top Left part.Reform
B
14

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

Bronchiectasis answered 31/3, 2016 at 17:50 Comment(0)
R
1

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

Reform answered 8/3, 2016 at 12:4 Comment(2)
That is system DPI-aware though. That's not per-monitor dpi-aware. So yeah the WPF application will scale when you change DPI settings in windows, but in Win10 you can have different monitors running with different DPI and as far as I understood that is not supported by WPF applications out of the box.Ianthe
The WPF uses DirectX to display anything on the monitor and as far as I can tell that is using directly your GPU to display content on the screen. So when you move your application from one monitor to another it will use different drawing context. This will work with multiple connections however if you use splitter cable it may not be the case. HTHReform

© 2022 - 2024 — McMap. All rights reserved.