Glow effect on MouseEnter WPF

Babak.Abad picture Babak.Abad · Aug 23, 2013 · Viewed 13k times · Source

I'm new in WPF(c#). I need make a glow effect around image control using triggers. How can I do make glow effect on mouse-enter event? I want to use your answer i my style.

My effect is:

<DropShadowEffect x:Key="MyEffect" ShadowDepth="0" Color="Blue" Opacity="1" BlurRadius="20"/>

I see many links but they don't work.

Answer

dkozl picture dkozl · Aug 23, 2013

To add glow to Image control you need to set Effect to your DropShadowEffect when IsMouseOver=True, something like this:

<Image Source="/WpfApplication1;component/myimage.png">
   <Image.Style>
      <Style TargetType="{x:Type Image}">
         <Style.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
               <Setter Property="Effect">
                  <Setter.Value>
                     <DropShadowEffect ShadowDepth="0" Color="Blue" Opacity="1" BlurRadius="20"/>
                  </Setter.Value>
               </Setter>
            </Trigger>
         </Style.Triggers>
      </Style>
   </Image.Style>
</Image>