<Grid>
<ItemsControl ItemsSource="{Binding ScreenViewModelCollection}">
<ItemsControl.Resources>
<DataTemplate DataType="{x:Type redScreenView:RedScreenView}">
<Grid>
<redScreenView:RedScreenView/>
</Grid>
</DataTemplate>
<DataTemplate DataType="{x:Type greenScreenView:GreenScreenView}">
<Grid>
<greenScreenView:GreenScreenView/>
</Grid>
</DataTemplate>
</ItemsControl.Resources>
</ItemsControl>
Instead of drawing the View for its ViewModel, it prints the namespace that the View belongs to!
But using an ItemTemplate works for just one of them. And ItemTemplate can’t have more than one content 🙁
Your
DataTemplatesare forViewswhile I suspect yourScreenViewModelCollectioncontainsViewModels.You just need to make the
DataTypeproperties beViewModelsinstead ofViews