I have a control that contains following XAML code. It works fine excepted that I caInnot switch to another TabItem. I read that TabControl
virtualizes the TabItem
, I suspect the strange behaviour, namely that I cannot get to display any other TabItem as the first one, is related to this.
<TabControl ItemsSource="{Binding Items}">
<TabControl.ItemTemplate>
<DataTemplate> <!-- header -->
<TextBlock Text="{Binding Title}"></TextBlock>
</DataTemplate>
</TabControl.ItemTemplate>
<TabControl.ContentTemplate>
<DataTemplate x:Shared="False"> <!-- tabitem content -->
<controls:ItemControl Item="{Binding}" />
</DataTemplate>
</TabControl.ContentTemplate>
</TabControl>
I tried to set the x:Shared
attribute of the DataTemplate
to False
but has not the expected effect. Is there a way to reach this without going the way of using a custom style and replacing the TabControl
with an ItemsControl
. I mean the functionality of TabControl
is what I would like, I would like to simply use it with ItemsSource
binding...
This behaviour will happen if you are binding to a collection that has duplicate objects in it. Duplication can occur due to having added an object multiple times or because equality has been redefined for the objects in question.