0

In Silverlight when I use an ListBox to display a list of items, I want the width of an element in each column to match the width of the equivalent elements displayed for all other items. I am using Grid In ItemTemplate with Auto Width Columns

For example, i want to display this:

Bob    | Marley  | 1986
Steve  | Jobs    | 2000
Bill   | Gates   | 1975
John   | Smith   | 1321
Andrew | Johnson | 2132

But i am getting this:

Bob| Marley| 1986
Steve| Jobs| 2000
Bill| Gates| 1975
John| Smith| 1321
Andrew| Johnson| 2132

I am using this code

<Grid>    
      <Grid.ColumnDefinitions>
          <ColumnDefinition Width="Auto"/>
          <ColumnDefinition Width="Auto"/>
          <ColumnDefinition Width="Auto"/>
       </Grid.ColumnDefinitions>


    <TextBlock Grid.Column="0" Text="{Binding Name}" HorizontalAlignment="Left"/>
    <TextBlock Grid.Column="1" Text="{Binding SecondName}" HorizontalAlignment="Left"/>
    <TextBlock Grid.Column="2" Text="{Binding Year}" HorizontalAlignment="LEft"/>

   </Grid>
Armen Mkrtchyan
  • 921
  • 1
  • 13
  • 34
  • http://stackoverflow.com/a/7737527/413032 – Davut Gürbüz Jul 02 '13 at 15:17
  • 1
    You are trying to use a ListBox such as a DataGrid. Simply use a DataGrid. Instead of looking for a workaround. This turn to re-implementation of DataGrid's `measure` methods again. It is already done for DataGrid. – Davut Gürbüz Jul 03 '13 at 06:38

0 Answers0