WPF style: difference between x: Name and x: Type

When defining a style in a resource dictionary, you can use

x:Name="xyz"

and

x:Type="xyz". 

and can reference this style in XAML, for example {StaticResource xyz}.

Most examples use "x: Key", and the difference between "name" and "key" is that using "x: name" allows you to use this style definition code?

FIXES: The question is completely wrong. What should have been set was the difference between x: Key and x: Name. But I did not try this code myself, but simply relied on memories - I thought that I had both in ResourceDictionary, which was wrong. And I also didn’t have such code in

 <xxx.Resources > 

. Style, x: Key (x: Name ) x: Key throws, (?) .

, .

+5
2

. ResourceDictionary,

x:Type="xyz"

x:Name="xyz"

:

  • x:Type="xyz" XAML.
  • x:Name="xyz" - XAML, ( ), .
  • x:Key="xyz" XAML, , .

, x:Key ( , FrameworkTemplate TargetType DataType). x:Name, , .

, x:Type , XAML, x:Name x:Key XAML. x:Type :

something="{x:Type whatever}"

x:Name x:Key , .

+9

x: , .

x: type ,

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

,

+2

All Articles