Hi
I have a ListBox that is bound to a list of Persons. I want to show the items of the listbox in a grid. I can accomplish this with the code below, but the problem is that with this code each item has its own grid. I want one grid to contain all items so that each column in the grid is automatically scaled to the width of the longest string. I suppose I should bind data to a Grid in stead? How?
<ListBox ItemsSource="{Binding}">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" Text="{Binding Path=Name}" />
<TextBlock Grid.Column="1" Text="{Binding Path=Age}" />
<TextBlock Grid.Column="2" Text="{Binding Path=Gender}" />
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>