image hover effect in wpf

image hover effect in wpf like 50% Transparent


like this way
How to create a css effect on image hover in wpf


private void image1_MouseEnter(object sender, MouseEventArgs e)
{
  DoubleAnimation brdAninamtion = new DoubleAnimation();
  brdAninamtion.From = 1.0;
  brdAninamtion.To = 0.5;
  brdAninamtion.Duration = new Duration(TimeSpan.FromMilliseconds(1));

  Storyboard.SetTargetName(brdAninamtion, "image1");
  Storyboard.SetTargetProperty(brdAninamtion, new PropertyPath(Border.OpacityProperty));

  Storyboard bdrStory = new Storyboard();
  bdrStory.Children.Add(brdAninamtion);
  bdrStory.Begin(image1);
}

private void image1_MouseLeave(object sender, MouseEventArgs e)
{
  DoubleAnimation brdAninamtion = new DoubleAnimation();
  brdAninamtion.From = 0.5;
  brdAninamtion.To = 1.0;
  brdAninamtion.Duration = new Duration(TimeSpan.FromMilliseconds(1));

  Storyboard.SetTargetName(brdAninamtion, "image1");
  Storyboard.SetTargetProperty(brdAninamtion, new PropertyPath(Border.OpacityProperty));

  Storyboard bdrStory = new Storyboard();
  bdrStory.Children.Add(brdAninamtion);
  bdrStory.Begin(image1);    
}

image hover effect in wpf image hover effect in wpf Reviewed by Bhaumik Patel on 9:15 AM Rating: 5