How to preserve mahapps metro styling when adding custom trigger?

前端 未结 1 493
日久生厌
日久生厌 2021-01-06 06:48

I had a button that was styled in the default metro style. However when I added a trigger to the button, the style is overridden. How to preserve the original mahapps metr

相关标签:
1条回答
  • 2021-01-06 07:15

    You need to set the "BasedOn" property of your style to the one mahapps.metro is providing as default:

    <Style TargetType="Button" BasedOn="{StaticResource MetroButton}">
    

    The documentation doesn't say the default static resource, but it's OpenSource so easy to track it down in the source code for the Controls.xaml you import to load the default styles in your app.xaml (or top of window etc):

    https://github.com/MahApps/MahApps.Metro/tree/develop/src/MahApps.Metro/Styles

    A search for TargetType="Button" finds our default style (without a key):

    Which is even also based on the base style, MahApps.Metro.Styles.MetroButton.

    0 讨论(0)
提交回复
热议问题