public class Meh : DependencyObject
{
public static readonly DependencyProperty MyPropertyProperty =
DependencyProperty.Register("MyProperty", typeof(string), typeof(Meh));
public string MyProperty
{
get { return (string)GetValue(MyPropertyProperty); }
set { SetValue(MyPropertyProperty, value); }
}
}
Now I databind that to a tab control using the following code
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
var data = new List<Meh>();
data.Add(new Meh { MyProperty = "One" });
data.Add(new Meh { MyProperty = "Two" });
TabControlViews.ItemsSource = data;
}
}
The XAML for the tab control looks like this
<TabControl Name="TabControlViews">
<TabControl.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding MyProperty}"/>
</DataTemplate>
</TabControl.ItemTemplate>
</TabControl>
This works fine and the tabs "One", "Two" appear on the tab control. However if I change the base type of Meh from DependencyObject to UserControl the tabs are blank. Why is this?