Hi,
Please see the attached project.
Simply put, when I bind the ItemsSource of the TabControl to an ObservableCollection of view models, more than one view is created, despite there being only one view model in the ObservableCollection.
This is demonstrated in the project by the fact that the following message is output to the console:
View created ... Id = 1
View created ... Id = 2
Clearly, this must mean that two views have been created since the id is incremented each time the TestView constructor is executed.
Please explain why this is the case because it doesn't happen with the Windows TabControl and as far as I can tell, this is pointless ... why waste resources creating two views per view model?!
Furthermore, this introduces subtle errors into any application that expects one view to be created per view model, which is how MVVM is expected to work!
Cheers,
James.
Attachment:
TestDataContract_8b0fbb53.rar