12

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?

Nick Sologoub
  • 724
  • 1
  • 7
  • 21
  • As long as you don't hard code values in you UI elements WPF app will scale it self automatically. – XAMlMAX Mar 08 '16 at 11:08
  • @XAMlMAX 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. – Nick Sologoub Mar 08 '16 at 11:55
  • Unrelated, but now I'm curious; what happens if your window is halfway between both monitors? – BTownTKD Mar 08 '16 at 14:44
  • 1
    @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. – XAMlMAX Mar 08 '16 at 15:43

2 Answers2

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

rohit21agrawal
  • 1,018
  • 10
  • 15
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

XAMlMAX
  • 2,268
  • 1
  • 14
  • 23
  • 1
    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. – Nick Sologoub Mar 08 '16 at 14:28
  • 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. HTH – XAMlMAX Mar 08 '16 at 14:40