Reputation: 1109
I have a tab control defined as this:
<TabControl Grid.Row="1" ItemsSource="{Binding Path=Documents}">
<TabControl.ItemTemplate>
<DataTemplate>
<TabItem>
<Button Content="Test button"/>
</TabItem>
</DataTemplate>
</TabControl.ItemTemplate>
</TabControl>
I know that the Documents collection in the ViewModel is updated properly since I can see an empty tab header when I run my application, thus tab items are being created by the control. But for some reason there is no button in the tab item. Any ideas why this is happening?
Upvotes: 1
Views: 93
Reputation: 33364
Remove TabItem
from your DataTemplate
as at the moment you put TabItem
within TabItem
.
<TabControl Grid.Row="1" ItemsSource="{Binding Path=Documents}">
<TabControl.ItemTemplate>
<DataTemplate>
<Button Content="Test button"/>
</DataTemplate>
</TabControl.ItemTemplate>
</TabControl>
also if you want to your Button
to appear in Content
part and not in the Header
then instead of ItemTemplate
use ContentTemplate
Upvotes: 4