Custom value converter will achieve the same goal.
public class BoolToBrushConverter : IValueConverter
{
public Brush FalseBrush { get; set; }
public Brush TrueBrush { get; set; }
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (value == null)
return FalseBrush;
else
return (bool)value ? TrueBrush : FalseBrush;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException("This converter only works for one way binding");
}
}
With this converter you can configure your XAML to: -
<Path Canvas.Top="20" Stroke="#FF808080" Data="M 0,20 20,0 40,20 Z" StrokeLineJoin="Round">
<Path.Fill>
<Binding Path="PumpRunning" ElementName="userControl">
<Binding.Converter>
<local:BoolToBrushConverter
FalseBrush="DarkGray" TrueBrush="DarkGreen" />
</Binding.Converter>
</Binding>
</Path.Fill>
</Path>
, , Path, Path, . , , .