Blendでデザイン時の幅と高さを指定する機能
Expression Blend 1.0(以下、Blend)とExpression Blend 2(以下、Blend 2)では、WPFのコントロールライブラリ(ユーザーコントロール)のプロジェクトを新規作成したときの「UserControl1.xaml」の内容が、下記のように異なっています。
Blend
<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="UserControl1"
x:Name="UserControl"
Width="640" Height="480">
<Grid x:Name="LayoutRoot"/>
</UserControl>
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="UserControl1"
x:Name="UserControl"
Width="640" Height="480">
<Grid x:Name="LayoutRoot"/>
</UserControl>
Blend 2
<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
x:Class="UserControl1"
x:Name="UserControl"
d:DesignWidth="640" d:DesignHeight="480">
<Grid x:Name="LayoutRoot"/>
</UserControl>
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
x:Class="UserControl1"
x:Name="UserControl"
d:DesignWidth="640" d:DesignHeight="480">
<Grid x:Name="LayoutRoot"/>
</UserControl>
違いを見比べていただくと、Blend 2のUserControl部分ではWidthとHeightが指定されておらず、代わりにDesignWidthとDesignHeightが指定されていることが分かるかと思います。これらは、以前の投稿でご紹介したXAML Readerに無視されるmc:Ignorable属性を使ったものになっており、実行時にはまったく影響を及ぼさないものです。
UserControlのような汎用的に利用する要素の場合、WidthとHeightは固定値を指定せずにAutoにしておくことが多いかと思います。しかしながら、BlendでUserControlのWidthとHeightを指定しない(つまり、WidthとHeightをAutoに設定した)場合、たとえば下記のようなXAMLは
<Grid x:Name="LayoutRoot">
<Grid.RowDefinitions>
<RowDefinition Height="0.5*"/>
<RowDefinition Height="0.5*"/>
</Grid.RowDefinitions>
<Button/>
<TextBox Grid.Row="1"/>
</Grid>
<Grid.RowDefinitions>
<RowDefinition Height="0.5*"/>
<RowDefinition Height="0.5*"/>
</Grid.RowDefinitions>
<Button/>
<TextBox Grid.Row="1"/>
</Grid>
このように表示されてしまうため、非常にデザインしずらい状態になってしまいます。
Blend
おそらくは暫定的にWidthとHeightを指定しておき、最後にそれらを削除するという手法を取っていた方が多かったのではないでしょうか。
Blend 2でDesignWidthとDesignHeightをそれぞれ300に設定した状態のデザイナの表示は下記のようになります。
Blend 2
これでもう暫定的にWidthとHeightを指定しておく必要はありません。