I am trying to nest a WrapPanel inside a DataGrid cell. What am I missing?
This is used to display sports team information. A Team has a TeamName, a Coach, a Roster of Players where each player has a FullName.
More technically speaking, the Roster property is a ObservableCollection where PlayerViewModel has FullName property.
<DataGrid ItemsSource="{Binding Teams}">
<DataGrid.Columns>
<DataGridTextColumn Header="Team Name" Binding="{Binding TeamName}" />
<DataGridTextColumn Header="Coach" Binding="{Binding Coach}" />
<DataGridTemplateColumn>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<WrapPanel DataContext="{Binding Roster}">
<Label Content="{Binding FullName}">
</WrapPanel>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
I figured it out. This worked.