Bind a TabControl to a data source
//File:Window.xaml.cs
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Collections.ObjectModel;
namespace TabControlUsingItemTemplate
{
public partial class Window1 : System.Windows.Window
{
public Window1()
{
InitializeComponent();
}
}
public class TabItemData
{
private string _header;
private string _content;
public TabItemData(string header, string content)
{
_header = header;
_content = content;
}
public string Header
{
get { return _header; }
}
public string Content
{
get { return _content; }
}
}
public class TabList : ObservableCollection
{
public TabList(): base()
{
Add(new TabItemData("Header 1", "Content 1"));
Add(new TabItemData("Header 2", "Content 2"));
Add(new TabItemData("Header 3", "Content 3"));
}
}
}