2016-03-22 26 views
1

Viewmodel özelliklerinden birini DropShadowEffect'in rengine bağlamak istiyorum. Bin çeşit varyasyon denedim ama hiçbiri işe yaramadı.DropShadowEffect Renk ciltleme çalışmıyor

stili:

<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> 

Kontrol:

<Image Source="{Binding CurrentPlayer.BackImageSource}" 
     Style="{DynamicResource ResourceKey=CentralImageStyle}"> 

ve dönüştürücü:

switch ((string)value) 
{ 
    case "char1": 
     return new SolidColorBrush(Colors.WhiteSmoke); 
    case "char2": 
     return new SolidColorBrush(Colors.Red); 
    default: 
     return new SolidColorBrush(Colors.White); 
} 

Benim sorunum DropShadowEffect rengi siyah olmasıdır. Bu, dönüştürücünün kullanılmadığı anlamına gelir.

cevap

1

Color özelliğine bağlanıyorsunuz ancak dönüştürücü Brushs'a dönüyor. SolidColorBrush'ları dönüştürücüden çıkarın ve sadece Colors.WhiteSmoke, Colors.Red, vb. Döndürün.

+0

Teşekkürler, bu benim sorunumu çözdü. –