Ask a questionAsk a question
 

AnswerCorrelation between DPI and dialog units

  • Friday, July 13, 2007 9:02 AMFrances83 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi all,

    I'm working on the UI for my app, and am trying to use the Vista UI Guidelines. On this page:

    Layout

    They're always talking about DLU's. What's the difference between DPI (which WPF uses) and DLU, and how do I switch between the two?

    Thanks,
    Frances

Answers

  • Wednesday, July 18, 2007 5:26 AMJacob Stanley Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Hi Frances

    Dialog units change in size based on the system font.

    1 dialog unit of width = 1/4 the average width of the system font
    1 dialog unit of height = 1/8 the average height of the system font

    For more information see: http://support.microsoft.com/kb/145994/en-us

    The layout page you linked to above also has a column for pixels, which from what I can see, seems to mean device-independent pixels. This is the unit WPF uses to specify lengths and sizes and is equal to 1/96th of an inch. So you can probably use those values directly in your Xaml. Can anyone from Microsoft confirm if this was the intention?

All Replies

  • Friday, July 13, 2007 3:58 PMMatt Hohn Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    DPI is relates to the current resolution of the screen and how the system is scaling fonts.  It used to be that WIN32 applications needed to be developed and made DPI aware, but this is one of the features that WPF handles for you, automatic DPI scaling.

     

    DLU describes spacing and sizing guidelines which is based on the current size of the font used in your application, which is effected by DPI.

     

    Another post on DLU

     

  • Monday, July 16, 2007 6:03 AMFrances83 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hmmm... So is there a way for me to calculate the number of DPI from the DLU, or should I just make an educated guess?
  • Wednesday, July 18, 2007 5:26 AMJacob Stanley Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Hi Frances

    Dialog units change in size based on the system font.

    1 dialog unit of width = 1/4 the average width of the system font
    1 dialog unit of height = 1/8 the average height of the system font

    For more information see: http://support.microsoft.com/kb/145994/en-us

    The layout page you linked to above also has a column for pixels, which from what I can see, seems to mean device-independent pixels. This is the unit WPF uses to specify lengths and sizes and is equal to 1/96th of an inch. So you can probably use those values directly in your Xaml. Can anyone from Microsoft confirm if this was the intention?
  • Wednesday, July 18, 2007 6:11 AMFrances83 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi Jacob,

    fancy 'seeing' you here Stick out tongue

    Hmmm, using the pixels... I'll give that a swing.
  • Monday, July 23, 2007 12:52 PMFrances83 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    I've tried the pixels, but I think this is not exaxctly what is needed. AS far as I can see, the distances are too small.

    Can someone from Microsoft please tell if I'm doind the right thing here?