在WPF中设置样式TargetType

时间:2013-12-19 22:22:58

标签: c# wpf xaml

设置样式的TargetType这两种方式之间有区别吗?

<Style TargetType="Grid"></Style>

<Style TargetType="{x:Type Grid}"></Style>

1 个答案:

答案 0 :(得分:3)

没有区别。您只是显式添加x:Type属性。默认情况下,WPF使用您在TargetType中添加的{x:Type}来解析它

编辑:

当您使用自定义控件时,您希望explitly设置{x:Type CustomControl}