How to bind items of a TabControl to an observable collection in wpf? How to bind items of a TabControl to an observable collection in wpf? wpf wpf

How to bind items of a TabControl to an observable collection in wpf?


Basic example :

<Window.Resources>    <DataTemplate x:Key="templateForTheContent" DataType="{x:Type vm:TheViewModelType}">        <v:YourUserControl/>    </DataTemplate>    <DataTemplate x:Key="templateForTheHeader" DataType="{x:Type vm:TheViewModelType}">        <TextBlock Text="{Binding ThePropertyToDisplayInTheHeader}"/>    </DataTemplate></Window.Resources>...<TabControl ItemsSource="{Binding YourCollection}"            ContentTemplate="{StaticResource templateForTheContent}"            ItemTemplate="{StaticResource templateForTheHeader}"></TabControl>