1
ViewModelのプロパティの1つをDropShadowEffectのカラーにバインドしたいとします。何千ものバリエーションのように試しましたが、どれも動作していないようです。DropShadowEffectカラーバインディングが機能しない
スタイル:
<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>
コントロール:
<Image Source="{Binding CurrentPlayer.BackImageSource}"
Style="{DynamicResource ResourceKey=CentralImageStyle}">
およびコンバータ:
switch ((string)value)
{
case "char1":
return new SolidColorBrush(Colors.WhiteSmoke);
case "char2":
return new SolidColorBrush(Colors.Red);
default:
return new SolidColorBrush(Colors.White);
}
私の問題はDropShadowEffectの色が黒であるということです。これはコンバータが使用されていないことを意味します。
ありがとう、それは私の問題を解決しました。 –