我有一个Silverlight ListBox,它使用DataTemplate作为ItemTemplate。我的DataTemplate和ListBox如下所示:
<DataTemplate x:Key="myTemplate">
<Grid Background="Green" HorizontalAlignment="Stretch">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding Name}" Grid.ColumnSpan="2" />
<TextBlock Text="{Binding PhoneNumber}" Grid.ColumnSpan="2" Grid.Row="1" />
<TextBlock Text="{Binding Age}" Grid.Row="2" />
<TextBlock Grid.Column="1" Grid.Row="2" HorizontalAlignment="Right"
Text="{Binding BirthDate}" />
</Grid>
</DataTemplate>
<ListBox x:Name="myListBox" Background="Yellow"
ItemTemplate="{StaticResource myTemplate}"
ItemsSource="{Binding People}" />
运行此代码时,我发现每个人的生日都不是完全右对齐的。相反,它与特定项目相对应。我希望ItemTemplates Grid拉伸到ListBox的整个宽度。我该怎么做呢?我究竟做错了什么?