Design time resources and Attributes in Silverlight/WPF/WP7

When you open a Silverlight/WPF/WP7 application in design mode in Visualstudio or Expression Blend, we may not see the exact look as we expect and see at runtime because of designtime.

There are several reasons for this, major reasons are:

–          Controls are not embedded in a view(Majorly this problem will come if we don’t give width and height)

–          Constructor of a root element is not called.

–          ViewModel is not created

to avoid this you need to provide information to make design view correctly.  You can specify this kind of information by using the design-time attributes.

The designtime attributes are defined in a special namespace, that is usually mapped to the d: prefix. To tell the XAML parser not to interprete these attributes at runtime, the markup compatibility namespace is mapped to mc: and with the mc:Ignorable="d" instruction, the d: namespace is excluded.


   xmlns:d =""
   mc:Ignorable="d" />

d:DesignHeight and d:DesignWidth:

The d:designHeight and d:DesignWidth are used to provide fixed height and width at design time.


    d:DesignWidth="640" d:DesignHeight="480" >
<UserControl />


If a property is set to a control at runtime and if we want to change this property at design time we can use the LayoutOverrides.


<Border Height="250" Width="160" d:LayoutOverrides="Width, Height" >

For more information see MSDN