There is a style in shared resources.

<Style TargetType="Button"> *** </Style> 

That is, when I add a resource to a form, the style described above is applied to all buttons. But if I add triggers to the button, the style is overwritten. It looks like this

 <Button> <Button.Resources> <Style TargetType="Button"> <Style.Triggers> *** </Style.Triggers> </Style> </Button.Resources> </Button> 

That is, the button ceases to inherit the style that is described in the core resource. And in the button resources I cannot specify for the BasedOn style, because that style does not have x: Key, and if you set it, then this style will fly off all the buttons in the entire project and you will have to explicitly set it. What to do?

    1 answer 1

    In BasedOn you can specify the type as a key, then it will pick up the default style for this control:

     <Button> <Button.Resources> <Style TargetType="Button" BasedOn="{StaticResource {x:Type Button}}"> <Style.Triggers> *** </Style.Triggers> </Style> </Button.Resources> </Button> 

    More information and examples are in MSDN .