I have a TabControl
I followed the answer chosen here to the letter. The thing is that in my case the ExistingTabs is not an ObservableCollection, but the property of an ObservableCollection:
Public Class TestData : INotifyPropertyChanged // and the required event handler is there also, not shown here
{
public TabItem tiTestTab {get; set;}
// another dozen properties
}
and
public class ReportData
{
public static ObservableCollection<TestData> testData {get;set;}
// another dozen properties
}
Here's what I did:
<Window.Resources>
<CollectionViewSource x:Key="ExistingTabs" Source="{Binding Path=(local:ReportDataSet.testData), Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
</Window.Resources>
<TabControl>
<TabControl.ItemsSource>
<CompositeCollection>
<TabItem>SomeSpecialItem</TabItem>
<CollectionContainer Collection="{Binding Source={StaticResource ExistingTabs}}"/>
</CompositeCollection>
</TabControl.ItemsSource>
</TabControl>
This, of course, places the testData in the tabs and not the tiTestTab property.
I am at a loss.
Preferably, XAML-only. Using C# and Visual Studio 2013.
Thanks.