Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Secondary accent color in WPF using Material Design

I have a button using accent style

 <Button Grid.Column="1" Grid.Row="0" Height="90" Width="90" VerticalAlignment="Top" Margin="15"
                    Style="{StaticResource MaterialDesignFloatingActionAccentButton}" >
                <materialDesign:PackIcon Kind="Alert" Height="40" Width="40" />
            </Button>

But I want this specific button to use a red accent style and not my default accent which is lime.

This will only happen in this specific window.

How do I achieve this?

Thanks

like image 371
Vallo Avatar asked Nov 25 '25 07:11

Vallo


1 Answers

You need to redefine the secondary accent brush in the resources of your button

<Button Grid.Column="1" Grid.Row="0" Height="90" Width="90" VerticalAlignment="Top" Margin="15"
        Style="{StaticResource MaterialDesignFloatingActionAccentButton}">
    <Button.Resources>
        <SolidColorBrush x:Key="SecondaryAccentBrush" Color="#F44336"/>
        <SolidColorBrush x:Key="SecondaryAccentForegroundBrush" Color="#E57373"/>
    </Button.Resources>

    <materialDesign:PackIcon Kind="Alert" Height="40" Width="40" />
</Button>

I hope it can help you.

like image 137
Il Vic Avatar answered Nov 26 '25 21:11

Il Vic



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!