I am able to access properties of an XAML control items directly. For instance, changing a header of a tab in a Dockpane
<CODE><SPAN class="" style="border: 0px; font-weight: inherit; font-size: 14px;"><SPAN style="border: 0px; font-weight: inherit; font-size: 14px;">XAML (View):</SPAN>
</SPAN>
<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>
<SPAN style="color: #000000;"><SPAN class="" style="border: 0px; font-weight: inherit; font-size: 14px;">
C# (Model):
private void FavoritesTabs_Initialized(object sender, EventArgs e)
{
Tab1.Header = "MyFavoriteTab";
}</SPAN><SPAN class="" style="border: 0px; font-weight: inherit; font-size: 14px;">
</SPAN></SPAN><SPAN class="" style="color: #999999; border: 0px; font-weight: inherit; font-size: 14px;">
</SPAN>
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
<SPAN class="" style="border: 0px; font-weight: inherit; font-size: 14px;"><SPAN style="border: 0px; font-weight: inherit; font-size: 14px;">XAML:</SPAN>
</SPAN>
<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>
<SPAN style="color: #000000;"><SPAN class="" style="border: 0px; font-weight: inherit; font-size: 14px;">
</SPAN><SPAN class="" style="border: 0px; font-weight: inherit; font-size: 14px;">
</SPAN></SPAN>
What else I should add Dockpane1ViewModel.cs (View Model) and Dockpane1.xaml.cs (Model)?