The default unit of measurement in Windows Forms was pixels. This worked well when most monitors on the market used a simple 96 pixel per inch measurement, but measuring by pixel causes problems when working with devices that have different resolutions. For example, with Windows Forms, a 100 pixel button would appear to be about an inch wide on a 96 pixel/inch monitor. However, on a 120 pixel/inch monitor, the same button would appear to be 4/5 of an inch. A 160 pixel/inch monitor would show the button as 5/8 of an inch. And on a 60 pixel/inch screen, the button would appear to be about 1 2/3 inches wide.
With the introduction of WPF, Microsoft began using DIU (Device Independent Units). A DIU (also known as a Device Independent Pixel, or DIP) measurement is based on inches rather than hardware-specific pixels. A DIU is defined as 1/96 of an inch (smaller than the point, which is defined as 1/72 of an inch). For a standard 96 pixel per inch monitor, 96 DIU = 96 pixels. For monitors with 120 pixels/inch, 96 DIU = 120 pixels. For a monitor with 60 pixels/inch, 10 DIU = 60 pixels. When the measurement doesn't work out to a perfectly round number (as is often the case), WPF will automatically use anti-aliasing, or you have the option of “snapping” to the nearest pixel if you don't want "fuzzy" outlines for your button, etc.
One kink is that all measurements, including text, are now measured in DIU. In Windows Forms, depending on what control you were using, font size was often measured in points (a point is 1/72 of an inch and is the measurement used in Word and other applications). So now when you specify font size 12, you are actually specifying a 9 point font (which is probably smaller than you intended).
To help with this transition, I've put together a quick chart to quickly convert inches and points into DIU. I hope this helps:
Units of Measurement
Inches
| Points
| DIU
|
1/96 | 3/4 | 1 |
1/72 | 1 | 1 1/3 |
1/48 | 1 1/2 | 2 |
1/32 | 2 1/4 | 3 |
1/24 | 3 | 4 |
1/16 | 4 1/2 | 6 |
1/12 | 6 | 8 |
1/8 | 9 | 12 |
5/36 | 10 | 13 1/3 |
1/6 | 12 | 16 |
3/16 | 13 1/2 | 18 |
1/4 | 18 | 24 |
1/3 | 24 | 32 |
1/2 | 36 | 48 |
3/4 | 54 | 72 |
1 | 72 | 96 |
1 1/2 | 108 | 144 |
2 | 144 | 192 |
3 | 216 | 288 |
4 | 288 | 384 |
5 | 360 | 480 |
8 | 576 | 768 |
10 | 720 | 960 |
11 1/2 | 828 | 1104 |
12 | 864 | 1152 |
* 'Device-Independent Units' (DIU) are also called 'Device-Independent Pixels' (DIP)
View on CodeProject