I have a DataTemplate on my App.XAML
<DataTemplate DataType="{x:Type ViewModels:MSMemberViewModel}">
<Views:MSMemberView>
</Views:MSMemberView>
</DataTemplate>
Which I use to create views in a tabcontrol, inside another view:
<TabControl ItemsSource="{Binding Tabs}" SelectedIndex="{Binding SelectedIndex}">
<TabControl.ItemTemplate>
//...
</TabControl.ItemTemplate>
<TabControl.ContentTemplate>
<DataTemplate>
<ContentControl Content="{Binding ViewModel}">
</ContentControl>
</DataTemplate>
</TabControl.ContentTemplate>
</TabControl>
The Tabs is an ObservableCollection of objects containing the tab name and the ViewModel.
New ViewModels are instantiated every time I add a new tab to the ObservableCollection (I know this because the constructor is called everytime I add a new tab), and my code to number the tab names works (because every tab has a different name), but the View is duplicated! How do I get around this?
Edit:
Also, none of the ViewModels on the ObservableCollection reflect the current values of the instantiated ViewModel/View on debug.