TargetType=“controlType"之间的区别和 TargetType=“{x:Type controlType}"; [英] Difference between TargetType="controlType" and TargetType="{x:Type controlType}"
问题描述
在 WPF 中,您可以将 TargetType
设置为类型的名称,也可以将其设置为 {x:Type nameOfType}
.
In WPF you can set the TargetType
to either the name of the type or you can set it to {x:Type nameOfType}
.
有人知道有什么区别吗?
Does anyone know what the difference is?
推荐答案
没什么.由于属性类型是 Type
,XAML 解析器知道尝试将您提供的任何内容转换为 Type
.在其他情况下,属性类型可能不太具体(例如 Object
),这就是您需要标记扩展的地方,否则 XAML 解析器只会将您的值解释为 String代码>.
Nothing. Since the property type is Type
, the XAML parser knows to try and convert whatever you supply to a Type
. In other scenarios, the property type might be less specific (eg. Object
), and that's where you need the markup extension, otherwise the XAML parser will just interpret your value as a String
.
这篇关于TargetType=“controlType"之间的区别和 TargetType=“{x:Type controlType}";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!