C
C#2mo ago
intee_

✅ Change WPF element style depending on property value

Hey, trying to set the "disabled" color of a button in my little practice app. I have the button setup with a command binding so that unless something is selected in a datagrid, the button is disabled. I tried setting up a style trigger but assuming whatever is handling disabling the button automatically is not setting the "Disabled" property though.
<Style TargetType="Button">
<Setter Property="Margin" Value="10, 5, 10, 5"/>
<Setter Property="Height" Value="40"/>
<Setter Property="Background" Value="#444"/>
<Setter Property="Foreground" Value="WhiteSmoke"/>
<Setter Property="FontSize" Value="16"/>
<Style.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Background" Value="#666"/>
</Trigger>
</Style.Triggers>
<Style TargetType="Button">
<Setter Property="Margin" Value="10, 5, 10, 5"/>
<Setter Property="Height" Value="40"/>
<Setter Property="Background" Value="#444"/>
<Setter Property="Foreground" Value="WhiteSmoke"/>
<Setter Property="FontSize" Value="16"/>
<Style.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Background" Value="#666"/>
</Trigger>
</Style.Triggers>
I'm just trying to make the white color in the screenshot , set to the #666 value.
No description
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server