<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
最佳答案
DataTemplate
只有一个 DataType
.
关于c# - 在 DataTemplate 上找不到 TargetType 属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11308994/