#759 – Device-Independent Units (DIPs)

(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.

About Sean
Software developer in the Twin Cities area, passionate about .NET technologies. Equally passionate about my own personal projects related to family history and preservation of family stories and photos.

2 Responses to #759 – Device-Independent Units (DIPs)

  1. Pingback: Dew Drop – February 19, 2013 (#1,501) | Alvin Ashcraft's Morning Dew

  2. Pingback: Weekly Digest 2 | chodounsky

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: