February 19, 2013 2 Comments
(Also known as WPF Units)
In WPF, when you’re specifying size or position for user interface elements, the values are always by default in Device-Indepdent Units (DIPs).
1 DIP = 1/96 inch. This means at 96 dpi, 1 DIP = 1 pixel.
At 120 dpi, 1 DIP = 1.25 pixels. (120/96)
The purpose of using DIPs when indicating desired size or position is that controls will still have the same physical size on your screen, regardless of the DPI setting. A button that is specified as being 96 DIPs wide will be 1″ wide, whether your display is set to 96 DPI, 120 DPI, or 150 DPI.
To convert from DIPs to pixels, you need to know your screen DPI setting (e.g. 96, 120):
# pixels = (DIPs) * (DPI / 96)
So 96 DIPs = 96 pixels at 96 DPI, and 96 DIPs = 120 pixels at 120 DPI.