Click here to Skip to main content
15,912,329 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
Hello, I am reading:
Working with Animations Programmatically[^]

and I am trying to make the first example.

I get errors that
C#
myStoryboard and myPointAnimation do not exist?
???
Please, what am I missing, any links or hints? I am new here, many thanks!!!

What I have tried:

myPointAnimation.To = myPoint;
myStoryboard.Begin();
Posted
Comments
Sergey Alexandrovich Kryukov 20-Jun-16 14:17pm    
Excuse me, we cannot see your example. It's not clear what would make you thinking that myStoryboard or myPointAnimation should exist if you, for example, never defined them or not properly named. You don't even have anything to ask the author of the article. Make a comprehensive minimal code sample; without it, you cannot ask some reasonable question and get some help.
—SA
Member 12581582 20-Jun-16 14:33pm    
.xaml

<Canvas MouseLeftButtonDown="Handle_MouseDown"
Background="Gray" Width="600" Height="500">
<Canvas.Resources>
<storyboard x:name="myStoryboard">

<!-- The PointAnimation has a name so it can be accessed
from code. The To property is left out of the XAML
because the value of To is determined in code. -->
<PointAnimation
x:Name="myPointAnimation"
Storyboard.TargetProperty="Center"
Storyboard.TargetName="MyAnimatedEllipseGeometry"
Duration="0:0:2"/>

</Canvas.Resources>

<Path Fill="Blue">
<Path.Data>

<!-- Describes an ellipse. -->
<ellipsegeometry x:name="MyAnimatedEllipseGeometry"
="" center="200,100" radiusx="15" radiusy="15">
</Path.Data>
</Path>

</Canvas>


.cs
private void Handle_MouseDown(object sender, MouseButtonEventArgs e)
{
// Retrieve current mouse coordinates.
double newX = e.GetPosition(null).X;
double newY = e.GetPosition(null).Y;
Point myPoint = new Point();
myPoint.X = newX;
myPoint.Y = newY;
myPointAnimation.To = myPoint;
myStoryboard.Begin();
}
Member 12581582 20-Jun-16 14:52pm    
Both are define din .xaml, is that not enough?
Richard Deeming 20-Jun-16 15:52pm    
That example is for Silverlight. Your question is tagged as WPF.

Although they have many similarities, they are two completely different technologies. If you're using WPF, you need to find a WPF tutorial. For example: Animation Overview[^]

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900