I want to lighten a buttons background on click. So I did the following:
<converter:ColorLightConverter x:Key="colorLightConverter" />
...
<Style BasedOn="{StaticResource default}" TargetType="{x:Type controls:Button}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type controls:Button}">
<ControlTemplate.Triggers>
<Trigger Property="IsPressed" Value="True">
<Setter Property="Background">
<Setter.Value>
<SolidColorBrush Color="{Binding Path=Background.Color, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource colorLightConverter}}" />
</Setter.Value>
</Setter>
</Trigger>
</ControlTemplate.Triggers>
<Border Background="{TemplateBinding Background}"
BorderBrush="Transparent"
BorderThickness="0">
...
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
The converter:
class ColorLightConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
Color color = (Color)value;
System.Drawing.Color lightColor = ControlPaint.Light(System.Drawing.Color.FromArgb(color.A, color.R, color.G, color.B));
return Color.FromArgb(lightColor.A, lightColor.R, lightColor.G, lightColor.B);
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}
But the converter isn't called when I click the button. I think there is anything wrong with the binding, but I can't see the error...
Can you help me?
Maybe I'm completely wrong. What I basically want to do: When clicking the button, take the current background color and lighten it. Not more...