tags:

views:

164

answers:

1

Hi,

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 named Items. My TabControl.ItemsSource is binded to Items property so the TabItems is 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 TabItems 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?

A: 

Hi Marcelo,

Have you tried

<TabControl ItemsSource="{Binding Items}" 
            ItemContainerStyle="{StaticResource MyTabItem}/>"

?

Anvaka
Ohhh man!!! thats so easy!...Tks!!!
Marcelo de Aguiar