Итак, я определяю DataTemplate в UserControl.Resources следующим образом:
<DataTemplate x:Key="Impact">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0"
Text="Impact:" />
<ComboBox Grid.Column="1"
ItemsSource="{Binding Impacts}">
</ComboBox>
</Grid>
</DataTemplate>
Затем я определяю ItemsControl следующим образом в визуальном дереве:
<ItemsControl ItemsSource="{Binding Path=ViewModelsList}">
<ItemsControl.Resources>
<DataTemplate DataType="{x:Type ui:FirstViewModel}">
<ContentControl ContentTemplate="{StaticResource Impact}"></ContentControl>
</DataTemplate>
<DataTemplate DataType="{x:Type ui:SecondViewModel}">
<ContentControl ContentTemplate="{StaticResource Impact}"></ContentControl>
...
</DataTemplate>
</ItemsControl.Resources>
</ItemsControl>
IsЕсть ли способ связать это {Binding Impacts}
в ресурсах с соответствующим типом ViewModel, определенным в DataType DataTemplate?
Может быть, есть способ передать DataType в ContentControl?