Animations inside Wpf

Page 1 of 1

4 Replies - 1721 Views - Last Post: 27 December 2011 - 12:21 PM Rate Topic: -----

#1 Andrei95  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 22
  • Joined: 17-December 11

Animations inside Wpf

Posted 27 December 2011 - 03:22 AM

Hello guys!
First of all I am new here and this is my first post, so please don't get mad if I make some mistakes :turned:

Well, what I am trying to do is to animate an image with a glow, so when I put my mouse over that image the glow animation will start.

I tried something like this but it's not working and I don't know why :crazy:

 public void sageataGlow(Image imagine)
        {
            DoubleAnimation da = new DoubleAnimation();
            
            da.From = 0;
            da.To = 10;
            da.Duration = new System.Windows.Duration(TimeSpan.FromSeconds(5));

            imagine.BeginAnimation(OuterGlowBitmapEffect.GlowSizeProperty, da);

            //SolidColorBrush culoareGlow = new SolidColorBrush();
            ColorAnimation ca = new ColorAnimation();

            ca.From = Colors.Azure;
            ca.To = Colors.Red;
            ca.Duration = new System.Windows.Duration(TimeSpan.FromSeconds(5));

            imagine.BeginAnimation(OuterGlowBitmapEffect.GlowColorProperty, ca);

        }

   private void LogInFormSageataSus_MouseUp(object sender, MouseButtonEventArgs e)
        {
            logInForm.sageataGlow(LogInFormSageataSus);
        }



By the way I was searching over the MSDN site and I find out that I need a Storyboard to make my animation work. If I really need a Storyboard, could you please explain what is a Storyboard exactly and for what it is used mainly?

Thanks in advance
:)

Is This A Good Question/Topic? 0
  • +

Replies To: Animations inside Wpf

#2 janne_panne  Icon User is offline

  • WinRT Dev
  • member icon

Reputation: 428
  • View blog
  • Posts: 1,047
  • Joined: 09-June 09

Re: Animations inside Wpf

Posted 27 December 2011 - 03:32 AM

Where are you telling your DoubleAnimation the target of the animation? You can't animate an image with DoubleAnimation if the DoubleAnimation doesn't know that it has to target the image.

And that's where you need a storyboard.

There is a sample at the bottom of MSDN page:
http://msdn.microsof...storyboard.aspx
Was This Post Helpful? 0
  • +
  • -

#3 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6110
  • View blog
  • Posts: 23,670
  • Joined: 23-August 08

Re: Animations inside Wpf

Posted 27 December 2011 - 04:34 AM

Moved to WPF.
Was This Post Helpful? 0
  • +
  • -

#4 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5677
  • View blog
  • Posts: 12,211
  • Joined: 02-June 10

Re: Animations inside Wpf

Posted 27 December 2011 - 08:32 AM

Quote

Well, what I am trying to do is to animate an image with a glow, so when I put my mouse over that image the glow animation will start.


Any chance you have MS Expression Blend? I was just watching the Total Training for Express Blend video series and they did this very thing in a 1m20sec video using the Timeline feature. It was very cool and very easy.
Was This Post Helpful? 0
  • +
  • -

#5 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1526
  • View blog
  • Posts: 5,961
  • Joined: 21-March 08

Re: Animations inside Wpf

Posted 27 December 2011 - 12:21 PM

I have a blog post about creating animations from code...

http://eclipsed4utoo...ogrammatically/

I agree with tlhIn`toq, if you can get your hands on Expression Blend, use it for your animations. It's SOOOO much easier using Visual States and Storyboards(from the Timeline) than trying to do it in code.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1