In silverlight app I create tab items dynamically in code (MainView's code-behind):
TabItem tab = new TabItem();
CustomerView view = new CustomerView();
view.DataContext = customerViewModel; //or tab.DataContext = customerViewModel;??
tab.Content = view;
DataTemplate template = this.Resources["CustomTabItemHeader"] as DataTemplate;
tab.HeaderTemplate = template;
tabControl.Items.Add(tab);
CustomTabItemHeader (in MainView.xaml) looks like:
<UserControl.Resources>
<DataTemplate x:Key="CustomTabItemHeader">
<TextBlock Text="{Binding Path=DisplayName}"/>
</DataTemplate>
</UserControl.Resources>
CustomerViewModel has DisplayName property and it implements INotifyPropertyChanged interface. But DisplayName isn't displayed in the tab header. Can someone explain me why?