Pointanimation is also very simple. It is similar to the two animation mentioned above and has the same attributes, such as by, from, and to. The difference is that pointanimation is the target value from one point to another.
I have a reason to believe that everyone knows this. So I will not introduce it much. Just give two examples a hot dive.
Example 1: let the line move.
In this example, linegeometry is used as the animation target object to animated the startpoint and Endpoint attributes to make the straight line (actually a line segment) move.
[HTML]View plaincopyprint?
- <Grid>
- <Path horizontalalignment = "stretch" verticalalignment = "stretch"
- Stroke = "orange" strokethickness = "6">
- <Path. Data>
- <Linegeometry X: Name = "LG" startpoint = "25, 32" endpoint = "185, 97"/>
- </Path. Data>
- </Path>
- <Grid. Resources>
- <Storyboard X: Name = "STD" repeatbehavior = "forever" autoreverse = "true">
- <Pointanimation duration = "0: 0"
- Storyboard. targetname = "LG"
- Storyboard. targetproperty = "startpoint"
- To = "20,375"/>
- <Pointanimation duration = "0: 0"
- Storyboard. targetname = "LG"
- Storyboard. targetproperty = "endpoint"
- To = "407,490"/>
- </Storyboard>
- </Grid. Resources>
- </GRID>
Remember to activate the animation in the loaded event of the page.
[CSHARP]View plaincopyprint?
- // Constructor
- Public mainpage ()
- {
- Initializecomponent ();
- This. Loaded + = (sender, e) =>
- {
- This. STD. Begin ();
- };
- }
Example 2: animated curves.
In this example, three beziersegment points are animated, even if the beziersegment curve is "swimming.
[HTML]View plaincopyprint?
- <Grid>
- <Path horizontalalignment = "stretch" verticalalignment = "stretch"
- Stroke = "lightgreen" strokethickness = "12">
- <Path. Data>
- <Pathgeometry>
- <Pathfigure startpoint = "180,35">
- <Beziersegment X: Name = "PBM"
- Point1 = "28,180"
- Point2 = "200,270"
- Point3 = "412,700"/>
- </Pathfigure>
- </Pathgeometry>
- </Path. Data>
- </Path>
- <Grid. Resources>
- <Storyboard X: Name = "STD" repeatbehavior = "forever" autoreverse = "true">
- <Pointanimation duration = "0: 0"
- Storyboard. targetname = "PBM"
- Storyboard. targetproperty = "point1"
- From = "27,162" to = "415,145" type = "codeph" text = "/codeph"/>
- <Pointanimation duration = "0: 0"
- Storyboard. targetname = "PBM"
- Storyboard. targetproperty = "point2"
- To = "600,400"/>
- <Pointanimation duration = "0: 0"
- Storyboard. targetname = "PBM"
- Storyboard. targetproperty = "point3"
- To = "10,700"/>
- </Storyboard>
- </Grid. Resources>
- </GRID>
The background code activates the animation in the loaded event.
Well, this lesson is easy to pass.