Difference between DesignWidth and Width in UserControl in WPF

mohammad picture mohammad · Feb 19, 2014 · Viewed 31.5k times · Source

When I create a new UserControl in WPF, studio creates some XAML:

<UserControl x:Class="MOG.Objects.Date.Calender"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">

    <Grid>

    </Grid>
</UserControl>

In UserContol I can also add Width property. What is difference between DesignWidth and Width?

Answer

Rhyous picture Rhyous · Feb 19, 2014

d:DesignHeight and d.DesignWidth are for the Designer (the WYSIWYG), in Visual Studio or in Expression Blend. Height and Width are actually for runtime.