TICS Coding Standard Viewer 
TIOBE Software Quality Framework
Print-friendly version
©TIOBE Software www.tiobe.com
 
XAML Coding Standard
Search

STY$001Checked automatically with code checker

Synopsis:Do specify the target type of your style using the TargetType="{x:Type TypeName}" syntax
Language:XAML
Severity Level:1
Category:Styles


Description:

If you need to specify the target type of your style explicitly, you should favor the syntax that uses the x:Type markup extension. The reason for this is primarily that it guarantees consistency in your XAML code, but also that the use of the Typename-as-String alternative may lead to problems.

  <Style x:Key="MyCustomButtonStyle" TargetType="Button"/>

  <Style x:Key="MyCustomButtonStyle" TargetType="{x:Type Button}"/>

This recommendation also holds for other attributes that expect a Type value, such as ControlTemplate.TargetType or RelativeSource.AncestorType.