Victor
Victor

Reputation: 1

Changing UI Style in MahApps.Metro MessageDialog buttons

I have a custom theme for my application and I would like to change the Style of the buttons (color, border, etc..) of the Buttons generated by the MessageDialog to match my application theme. Is there a simple way to do this in XAML ?

Upvotes: 0

Views: 839

Answers (1)

mrsargent
mrsargent

Reputation: 2442

If you set your application theme in the app.xaml like below the standard mahapps.metro styles usually do a pretty good job of matching the application (including the mahapps MessageDialog).

app.xaml

<ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
            <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
            <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colors.xaml" />
            <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/Red.xaml" />
            <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml" />
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>

sample button styles

   <Button Style="{DynamicResource AccentedSquareButtonStyle}" />
   <Button Style="{DynamicResource MetroCircleButtonStyle}"/>

You can also change styles if sections of your code

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

You should check out MahMappsmetro and their Github

Hope that is what you were asking.

Upvotes: 0

Related Questions