c# - 在 DataTemplate 上找不到 TargetType 属性

标签 c# wpf xaml datatemplate

<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/

相关文章:

c# - 在 c# asp.net Core 中压缩图像

c# - 正确调整 wpf ListView 最后一列的大小

c# - 使用 linq to sql 将列表附加到数据库

c# - 如何使用 XAML 在整个容器(如 Panel 或 GroupBox)上设置 IsReadOnly/IsEnabled?

c# - Visual Studio 2019 WPF 设计器不会显示自定义控件

xaml - 使用扩展面板平等地拉伸(stretch)所有 child

c# - 如何将 GridColumn 绑定(bind)到 ObservableCollection 的索引值?

c# - 使用 View 模型中的 MVC View 返回 JsonResult 数据

c# - 'call command on property change' 功能应该去哪里?

c# - Windows Phone 中部分图像源与额外文本绑定(bind)