I want to bind "Header" of the TabItem properties on MVVM way.
I bind the "ItemsSource" property of the "XamTabControl" to a list of view models (List<MyTabItem>
MyTabItem is a viewmodel too).
Here is the XAML Code
<igWindows:XamTabControl
Height="198"
HorizontalAlignment="Left"
Margin="0,54,0,0"
ItemsSource="{Binding Tabs}"
Name="xamTabControl1"
VerticalAlignment="Top"
Width="651">
<!-- this is the body of the TabItem template-->
<igWindows:XamTabControl.ItemTemplate>
<DataTemplate>
<TextBlock
Text="{Binding Header}" />
</DataTemplate>
</igWindows:XamTabControl.ItemTemplate>
<igWindows:XamTabControl.ContentTemplate>
<!-- this is the body of the TabItem template-->
<DataTemplate>
<TextBlock
Text="{Binding Content}" />
</DataTemplate>
</igWindows:XamTabControl.ContentTemplate>
</igWindows:XamTabControl>
Here is the view model.
private ObservableCollection<TabItem> tabs;
public ObservableCollection<TabItem> Tabs
{
get
{
return tabs;
}
set
{
tabs = value;
NotifyPropertyChanged("Tabs");
}
}
To display the tab header, I have inserted a text block inside the ItemTemplate in XamlTabControl. I wanna display the header by using the "Header" property of the TabItemEx property instead of using text block. And I wanna do this to "CloseButtonVisibility" property too.