nNote Many Windows applications don??™t fully support higher DPI settings. At worst, increasing the system
DPI can result in windows that have some content that??™s scaled up, and other content that isn??™t, which can
lead to obscured content and even unusable windows.
This is where WPF is different. WPF respects the system DPI setting natively and effortlessly.
For example, if you change the system DPI setting to 120 dpi (a common choice for
users of large high-resolution screens), WPF assumes that it needs 120 pixels to fill an inch of
space. WPF uses the following calculation to figure out how it should translate its logical units
to physical device pixels:
[Physical Unit Size] = [Device-Independent Unit Size] 5 [System DPI]
= 1/96 inch 5 120 dpi
= 1.25 pixels
In other words, when you set the system DPI to 120 dpi, the WPF rendering engine
assumes one device-independent unit equals 1.25 pixels. If you show a 96-by-96 button, the
physical size will actually be 120 by 120 pixels (because 96 5 1.25 = 120). This is the result you
expect??”a button that??™s 1 inch on a standard monitor remains 1 inch in size on a monitor with
a higher pixel density.
This automatic scaling wouldn??™t help much if it only applied to buttons. But WPF uses
device-independent units for everything it displays, including shapes, controls, text, and any
other ingredient you put in a window.
Pages:
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88