<Grid>
<ItemsControl ItemsSource="{Binding ScreenViewModelCollection}">
<ItemsControl.Resources>
<DataTemplate x:Key="SomeKey" TargetType="{x:Type local:RedScreenObject}">
<local:RedScreenObject/>
</DataTemplate>
</ItemsControl.Resources>
</ItemsControl>
</Grid>
我不知道为什么它看不到TargetType属性。应该在Resources或ItemTemplate下面吗?我都试过了,但无论哪种方式都找不到它。
编辑: 为了获得更多的负分哈哈,这是参考以下内容: https://chat.stackoverflow.com/transcript/message/4295316#4295316