Is there any difference (or advantage) for use this statement:
Style x:Key="{x:Type DataGridCell}" TargetType="{x:Type DataGridCell}"
with omitting the x:Key
attribute?
I think WPF assigns the key to the same x:Type
under the hood.
Is there any difference (or advantage) for use this statement:
Style x:Key="{x:Type DataGridCell}" TargetType="{x:Type DataGridCell}"
with omitting the x:Key
attribute?
I think WPF assigns the key to the same x:Type
under the hood.
The MSDN documentation for
Style.TargetType
confirms your suspicions:If the resource dictionary key of a style is a type, that style is used as the default style for all instances of that type that don't explicitly specify a style. Since the target type is usually supplied, the syntax of omitting the key is simply a shortcut for defining a default style.