In my application I have a main window composed by some menus and menu-items and a TabControl
. In Window.DataContext
, I reference my ViewModel
that contains a property of type ObservableCollection<MyItemModel>
named Items
.
My TabControl.ItemsSource
is bound to the Items
property so the TabItem
s are declared dynamicaly:
<Window>
...
<Window.DataContext>
<local:ViewModel x:Name="model" />
</Window.DataContext>
...
<TabControl ItemsSource="{Binding Items}" />
</Window>
Now I want to define a Style
for my TabItem
s in App.xaml like this:
<App.xaml>
...
<Style TargetType="{x:Type TabItem}" x:Key="MyTabItem">
...
</Style>
...
<App.xaml>
And use this Style
in my Window
. But the problem is how if TabControl
does not have a property for ItemsStyle
or something like this?
Have you tried
<TabControl ItemsSource="{Binding Items}"
ItemContainerStyle="{StaticResource MyTabItem}/>"
?