I have HeaderedItemsControl
which ItemsSource is bound to a ObservableCollection<Person>
. I would like to display it's content like:
*Name* Müller Schmid Weber *FirstName* Peter Hans Willhelm *Age* 32 56 78 *Country* Switzerland Austria Liechtenstein
My xaml-Code so far:
<HeaderedItemsControl ItemsSource="{Binding Path=PersonCollection}">
<HeaderedItemsControl.Template>
<ControlTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<TextBlock Grid.Column="0" Grid.Row="0" Text="Name"/>
<TextBlock Grid.Column="0" Grid.Row="1" Text="FirstName"/>
<TextBlock Grid.Column="0" Grid.Row="2" Text="Age"/>
<TextBlock Grid.Column="0" Grid.Row="3" Text="Country"/>
<StackPanel Grid.RowSpan="4" Grid.Column="1" Orientation="Horizontal">
<ItemsPresenter/>
</StackPanel>
</Grid>
</ControlTemplate>
</HeaderedItemsControl.Template>
<HeaderedItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Vertical">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Label Grid.Row="0" Content="{Binding Path=Name}" />
<Label Grid.Row="1" Content="{Binding Path=FirstName}" />
<Label Grid.Row="2" Content="{Binding Path=Age}" />
<Label Grid.Row="3" Content="{Binding Path=Country}"/>
</StackPanel>
</DataTemplate>
</HeaderedItemsControl.ItemTemplate>
</HeaderedItemsControl>
This gives me something like:
*Name* Müller Schmid Weber *FirstName* Peter Hans Willhelm *Age* 32 56 78 *Country* Switzerland Austria Liechtenstein
Is there a way to let the items be presented in a column?