Over a million developers have joined DZone.

Windows Phone Mango Resources Part 3: Sizes

DZone's Guide to

Windows Phone Mango Resources Part 3: Sizes

· Mobile Zone
Free Resource

This is part 3 in the Resource series.

  1. Part 1: Themes
  2. Part 2: Colors
  3. Part 3: Sizes
  4. Part 4: Styles

What Sizes are there?

Another handy resource is the built-in size resources. This allows you to scale your fonts with two key benefits:

  1. Your font sizes will resemble the rest of the phone
  2. Your application will be ready for future resolutions

Let’s take a look at what sizes are available:


In the code above do you see how the double value does not match the point value specified in the comment? To understand this, we need to talk about the Silverlight Unit of Measurement.

Silverlight Measuring Units

You may already know that DPI is not the same as Pixels.

MSDN: Not all applications are DPI-aware: some use hardware pixels as the primary unit of measurement; changing the system DPI has no effect on these applications. Many other applications use DPI-aware units to describe font sizes, but use pixels to describe everything else.

Graphics and text at different DPI settings

Silverlight uses Layout Rounding

MSDN: Layout rounding is a concept in Silverlight whereby the Silverlight layout system rounds off any non-integral values that exist at the time of the layout render pass. Layout rounding has an API surface area of just a single API,UIElement.UseLayoutRounding, but the default layout rounding behavior that is built in to the layout system has implications for the visual appearance of your application.

The intention of layout rounding is to prevent subpixel rendering logic from producing antialiasing effects that generally are regarded as a poor visual presentation. One of the most extreme examples of this would be if you had a single-pixel straight black line on exactly a half-pixel boundary of the pixel grid. Subpixel rendering would average the pixels on either side of the .5 division. Instead of a single-pixel line of 100% black, it would render a 2-pixel wide line of 50% gray.

Silverlight Unit == Physical Pixel

Device-independent Pixels are a WPF thing (px (default) is device-independent units (1/96th inch per unit [when printing, rarely on screen])). Silverlight units of measure are physical pixels – meaning the actual pixel on the display.

MSDN: Double typing for the sizing properties in Silverlight is mostly for WPF compatibility. WPF supports a conversion behavior for other unit types, and also supports a device-independent pixel concept that has platform dependencies. Silverlight is cross-platform, and does not support the unit types; therefore, the conversion requirements that exist for WPF and require an underlying Double are seldom relevant in Silverlight programming.

Next: Part 4 – Styles

Source:  http://blog.jerrynixon.com/2011/12/mango-sample-resources-part-3-sizes.html


Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}