In this answer it is being (correctly? it seems..) claimed thant if you omit the x:Name
attribute the style is automatically applied everywhere.
If you don't specify an identifier on each Style, that style will apply to all controls that match with the TargetType you specified. If you want button to look different, you can do the same as above, but also include an identifier to that style, that will be used by each different button: [...]
However, when I add a x:Name
indentifier, it should not be automatically applied, or should it?
Because when I try this:
<Style TargetType="{x:Type TextBlock}" x:Name="RunningTextStyle">
<Setter Property="FontSize" Value="15" />
</Style>
in my ResourceDictionary
that is linked into my app.xaml
this way:
<Application.Resources>
<ResourceDictionary Source="ApplicationStyles.xaml" />
</Application.Resources>
It does still automatically apply to all TextBlock
s.
How do I create a style that has to be used with its indentifier to show up?
I use Resharper in VS2015 and the x:Key
name doesn't even show up when I try to add the style to a TextBlock
manually this way: Style="{StaticResource ...}"
definition as a possibility (I had it once this way and it did. It works, but normally it's being advertised by R# or VS to be used).
Interestingly enough, I had just a few hours before the other way around, where my Button
style wasn't automatically applied.