TargetType=“controlType"之间的区别和 TargetType=“{x:Type controlType}"; [英] Difference between TargetType="controlType" and TargetType="{x:Type controlType}"

查看:17
本文介绍了TargetType=“controlType"之间的区别和 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屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆