The BorderThicknessProperty is being applied correctly, but the ForeGroundProperty is not. I have tried swapping positions of the setters, thinking maybe only the first was being applied. I have tried a couple of other properties and none have work except BorderThickness. I am guessing I need to get to the Textblock of the Content, but I don't know how I would do that.
var foregroundSetter = new Setter()
{
Property = Button.ForegroundProperty,
Value = Brushes.LightGray
};
var borderThicknessSetter = new Setter()
{
Property = Button.BorderThicknessProperty,
Value = new Thickness(0)
};
var isEnabledTrigger = new Trigger()
{
Property = Button.IsEnabledProperty,
Value = false
//Setters = { foregroundSetter, borderThicknessSetter }
};
isEnabledTrigger.Setters.Add(foregroundSetter);
isEnabledTrigger.Setters.Add(borderThicknessSetter);
var style = new Style();
style.Triggers.Add(isEnabledTrigger);
var pdfButton = new Button()
{
Padding = new Thickness(0, 0, 0, 0),
Margin = new Thickness(0, 0, 5, 0),
Height = 18,
Width = 20,
Content = "PDF",
FontSize = 9,
FontWeight = FontWeights.SemiBold,
Foreground = Brushes.Red,
BorderBrush = Brushes.Transparent,
Background = Brushes.Transparent,
ToolTip = new ToolTip() { Content = "Create PDF of training day." },
Command = CreatePdfCommand,
CommandParameter = newTab,
Style = style
};
you assigned local value for Foreground property (
Foreground = Brushes.Red). After that style trigger may be triggered but a Foreground setter from trigger will be ignored because local value has more weight (it is called Dependency Property value precedence)to fix that behavior set normal Foreground value via style setter: