Reputation: 149
I'd like to bind one of the viewmodel's properties to the Color of a DropShadowEffect. I have tried like a thousand variations but none of them seemed to work.
The style:
<Style TargetType="{x:Type Image}" x:Key="CentralImageStyle">
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Effect">
<Setter.Value>
<DropShadowEffect ShadowDepth="0"
Color="{Binding Path=DataContext.CurrentPlayer.Character, Converter={StaticResource CharacterColorConverter},
RelativeSource={RelativeSource AncestorType={x:Type Window}}}"
Opacity="1" BlurRadius="50"/>
</Setter.Value>
</Setter>
</Trigger>
</Style.Triggers>
</Style>
The Control:
<Image Source="{Binding CurrentPlayer.BackImageSource}"
Style="{DynamicResource ResourceKey=CentralImageStyle}">
and the converter:
switch ((string)value)
{
case "char1":
return new SolidColorBrush(Colors.WhiteSmoke);
case "char2":
return new SolidColorBrush(Colors.Red);
default:
return new SolidColorBrush(Colors.White);
}
My problem is that the color of the DropShadowEffect is black. That kinda means that the converter isn't used.
Upvotes: 1
Views: 1102
Reputation: 214
You're binding to the Color property, but the converter is returning Brushes. Remove the SolidColorBrush's from the converter and just return Colors.WhiteSmoke, Colors.Red, etc...
Upvotes: 2