.netwpfxamltargettype

Difference between TargetType="controlType" and TargetType="{x:Type controlType}"


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?


Solution

  • 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.