I am able to access properties of an XAML control items directly. For instance, changing a header of a tab in a Dockpane
XAML (View):
<TabControl x:Name="FavoritesTabs" HorizontalAlignment="Stretch" Height="23" Initialized="FavoritesTabs_Initialized" Margin="8,0,7,0" >
<TabItem x:Name="Tab1" Height="20" Width="75"> </TabItem>
<TabItem x:Name="Tab2" Height="20" Width="75"></TabItem>
</TabControl>
C# (Model):
private void FavoritesTabs_Initialized(object sender, EventArgs e)
{
Tab1.Header = "MyFavoriteTab";
}
However, I know it this is not right/proper way and I would like to use MVVM. I would like to bind tab Headers to Model by using MVVM. How can I achieve that?
I think XAML would be
XAML:
<TabControl x:Name="FavoritesTabs" HorizontalAlignment="Stretch" Height="23" Initialized="FavoritesTabs_Initialized" Margin="8,0,7,0" >
<TabItem x:Name="Tab1" Header="{Binding MyFavorite1}" Height="20" Width="75"> </TabItem>
<TabItem x:Name="Tab2" Header="{Binding MyFavorite2}" Height="20" Width="75"></TabItem>
</TabControl>
What else I should add Dockpane1ViewModel.cs (View Model) and Dockpane1.xaml.cs (Model)?