I have following piece of XAML code:
<TabControl x:Name="MainTabControl" ItemsSource="{Binding Projects}" Grid.Row="1">
<TabControl.ItemTemplate>
<DataTemplate>
<TabItem x:Name="ProjectTabItem" Header="{Binding ProjectName}">
<TextBox>This text doesn't get displayed.</TextBox>
</TabItem>
</DataTemplate>
</TabControl.ItemTemplate>
</TabControl>
And C# code that I am binding to:
public IList<SharedProject> GetDummyData()
{
IList<SharedProject> projects = new List<SharedProject>();
SharedProject project1 = new SharedProject();
project1.Id = 1;
project1.ProjectName = "ProjectOne";
project1.ProjectDescription = "DescriptionOne";
project1.ProjectStartDate = DateTime.Now;
project1.ProjectEndDate = DateTime.Now.AddDays(30);
projects.Add(project1);
SharedProject project2 = new SharedProject();
project2.Id = 2;
project2.ProjectName = "ProjectTwo";
project2.ProjectDescription = "DesciptionTwo";
project2.ProjectStartDate = DateTime.Now;
project2.ProjectEndDate = DateTime.Now.AddDays(30);
projects.Add(project2);
return projects;
}
Binding Projects and ProjectName works, data gets displayed. The problem is, the content of the TabItem is not displayed, no matter what content I have (In this example just a TextBox). I noticed this problem only persist when I do Binding. If I remove binding from the TabControl and hardcode Header of the TabItem, everything works fine.
SharedProject
class as we can't tell if there are any errors in that class that might cause the problem without it. – Tony Vitabile