tags:

views:

11

answers:

1

Hello,

I have a Silverlight ListBox that uses a DataTemplate for the ItemTemplate. My DataTemplate and ListBox are shown here:

<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}" />

When running this code, I have discovered that each Persons birthdate is not fully right-aligned. Rather, it is right-aligned in relation to the specific item. I want the ItemTemplates Grid to stretch to be the full width of the ListBox. How do I do this? What am I doing wrong?

A: 

Found the answer here