fade Transparency on Image Control


Well-known member
Feb 2, 2013
Programming Experience

I am trying to fade a image control in from a set transparency to 100 %
a little history ....

the application's transparency can be set by the user, the options are from 100 % down
to 50 % ...what I want to do is animate
the transparency from where ever the user has it set to 100% , I already wrote the
code to switch the transparency which works fine until I add the code
below ...when I add this code , the transparency doesnt work any longer.

Animation Code on MouseEnter and MouseLeave Events

private void ThemeWindow_MouseEnter(object sender, MouseEventArgs e)
            Image w = (Image)sender;
               DoubleAnimation animation = new DoubleAnimation(1, TimeSpan.FromSeconds(2));
              w.BeginAnimation(Image.OpacityProperty, animation);

        private void ThemeWindow_MouseLeave(object sender, MouseEventArgs e)
            Image w = (Image)sender;
               DoubleAnimation animation = new DoubleAnimation(ThemeWindow.Opacity, TimeSpan.FromSeconds(2));
               w.BeginAnimation(Image.OpacityProperty, animation);

any help would be appreciated

Thank You
Top Bottom