WPF - Default Button Disable Style When Foreground applied

wpf

Solution

If you set the properties locally the trigger will not be able to change the value due to precedence.

Move the Foreground and IsEnabled property into the style:

<StackPanel>
<StackPanel.Resources>
    <Style TargetType="{x:Type Button}">
        <Setter Property="Foreground" Value="Red"/>
        <Setter Property="IsEnabled" Value="True"/>
        <Style.Triggers>
            <Trigger Property="IsEnabled" Value="false">
                <Setter Property="Foreground" Value="#FFADADAD"/>
            </Trigger>
        </Style.Triggers>
    </Style>
</StackPanel.Resources>
<Button Width="150" 
    Height="50"
    Content="Test">
</Button>

Problem

Button is applied with a `Foreground` when it is enabled. If it is Set as Disabled, default Button's Disabled `Foreground` need to apply. ``` <Button Width="150" Height="50" Content="Test" Foreground="Red" IsEnabled="False" /> ``` I have Triggers for this button like ``` <Trigger Property="IsEnabled" Value="false"> <Setter Property="Foreground" Value="#FFADADAD"/> </Trigger> ``` This `Foreground` is not applied when it is enabled. Any idea on this? Need like below,

Original source