I have an WPF application which contains several TabItems. Each TabItem is different from each other, with a text and an icon.
This is how the TabItem´s style is def
You just need to set the TabItem.DataContext
to an object that contains values for your TextBlock
and Image
controls:
In code:
public class TabItemData
{
public string ImageSource { get; set; }
public string Heading { get; set; }
}
In your Style
in XAML:
In your view model:
public class TabControlViewModel
{
public TabControlViewModel()
{
TabItemData = new TabItemData() { Header = "Some header",
ImageSource = "Images/IconLeafGrey.png" };
}
public TabItemData TabItemData { get; set; }
}
In XAML:
...
Of course, I've left out some initialisation of the data objects and the INotifyPropertyChanged
interface which you should implement, but I hope you get the idea.