Mahapps.metro: Using FlatButton in XAML ?

Created on 22 Apr 2015  路  5Comments  路  Source: MahApps/MahApps.Metro

From: http://mahapps.com/controls/buttons.html

This is the documentation on using a SquareButton:

Style="{DynamicResource SquareButtonStyle}"

This is the documentation on using a FlatButton:

_________________________ (nothing)

Please advise. I saw the bit on importing the ResourceDictionary, but there's nothing on actually using it.

Barry

Most helpful comment

@barryBithead the flat style exists in

<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.Buttons.xaml" />

or in (for back compatibility)

<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/FlatButton.xaml" />

and can be used by the MetroFlatButton style key

    <Style TargetType="{x:Type Button}"
           BasedOn="{StaticResource MetroFlatButton}" />

All 5 comments

@barryBithead the flat style exists in

<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.Buttons.xaml" />

or in (for back compatibility)

<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/FlatButton.xaml" />

and can be used by the MetroFlatButton style key

    <Style TargetType="{x:Type Button}"
           BasedOn="{StaticResource MetroFlatButton}" />

@punker76 I think @barryBithead is referring to the fact that in the documentation for all other buttons the required style is stated. Only for FlatButton it is mentioned to add the additional resource, but not the name of the style.

@thoemmi yeah, side note: update docu :-D

Well, I just consulted the source code: FlatButton.xaml contains <Style TargetType="{x:Type Button}" BasedOn="{StaticResource MetroFlatButton}" />, so as soon as you add that file to your resource dictionary, all buttons will use the MetroFlatButton.

The style itself is defined in Controls.Buttons.xaml, i.e. you don't have to include FlatButton.xaml but just use the style MetroFlatButton.

Or am I wrong?

Thanks for the info. I discovered my buttons went "flat" once the library was imported to the MergedDictionaries. The documentation didn't tell me that though, or a specific tag to use to enable it, like the tags mentioned for the other styles. thanks again...

Was this page helpful?
0 / 5 - 0 ratings