Reputation: 3951
I'm using TabControl
to present data from different DataTable
s. With this XAML code:
<TabControl Margin="5, 5, 5, 5"
HorizontalAlignment="Stretch"
DockPanel.Dock="Top"
ItemsSource="{Binding Path=ItemInfoViewModels}">
<TabControl.ItemTemplate>
<DataTemplate>
<StackPanel>
<TextBlock Text="{Binding EditingTable.Name}"></TextBlock>
<ContentControl>
<Partials:ItemInfo />
</ContentControl>
</StackPanel>
</DataTemplate>
</TabControl.ItemTemplate>
</TabControl>
I get a view that looks like this:
which is obviously wrong. Everything - header text and content - is displayed where normally Header
would be shown. So how can I change my XAML, so that it would look as it should?
Upvotes: 0
Views: 96
Reputation: 24453
Try using ContentTemplate
instead of ItemTemplate
. ItemTemplate
is applied to the Header
of each TabItem
, ContentTemplate
is used to display the selected tab.
You could alternatively set the ItemContainerStyle
and manipulate the settings on the TabItems
more directly.
Upvotes: 1