XAML
< Usercontrol X: Class = "Silverlight. Common. test"
Xmlns = "Http://schemas.microsoft.com/winfx/2006/xaml/presentation"
Xmlns: x = "Http://schemas.microsoft.com/winfx/2006/xaml"
Xmlns: d = "Http://schemas.microsoft.com/expression/blend/2008"
Xmlns: MC = "Http://schemas.openxmlformats.org/markup-compatibility/2006"
MC: ignorable = "D"
D: designheight = "300" D: designwidth = "400" >
< Stackpanel Horizontalalignment = "Left" >
< Stackpanel Orientation = "Horizontal" >
< Button Width = "65" Height = "30" Margin = "2" Content = "Begin" Click = "Button_click" />
< Button Width = "65" Height = "30" Margin = "2" Content = "Pause" Click = "Button_click_1" />
< Button Width = "65" Height = "30" Margin = "2" Content = "Resume" Click = "Button_click_2" />
< Button Width = "65" Height = "30" Margin = "2" Content = "Stop" Click = "Button_click_3" />
</ Stackpanel >
< Path Fill = "Green" >
< Path. Data >
< Ellipsegeometry X: Name = "Ellipse" Center = "50, 50" Radiusx = "15" Radiusy = "15" />
</ Path. Data >
</ Path >
< Stackpanel. Resources >
<! -- Pointanimation-linear interpolation animation between two point values -->
<! --
Storyboard. targetname-name of the object to be animated
Storyboard. targetproperty-attributes of the object to be animated
Begintime-the timeline can be played only after the time when the intime is triggered.
Timespan-[-] [day.] hour: minute: the number of digits after the second [. 1 to 7] (positive, negative, or NULL; default value: 0)
From-animation start value
To-animation end value
By-the total amount of changes required for an animation from the start value (to takes precedence over)
Duration-timeline duration
Timespan-[-] [day.] hour: minute: Second [decimal point after. 1 to 7]
Automatic confirmation
Forever-unlimited length
Autoreverse-whether to return the original path after the animation is completed. The default value is false.
Repeatbehavior-time, number of times, or type of repeated animation playback
Timespan-[-] [day.] hour: minute: Second [decimal point after. 1 to 7]
NX-Playback times. 1x, 2x, 3x
Forever-permanent playback
Speedratio-a multiple of the time series rate. Default Value: 1
Fillbehavior-behavior after the animation ends [system. Windows. Media. animation. fillbehavior enumeration]
Fillbehavior. holdend-the animation attribute end value is retained after the animation ends. Default Value
Fillbehavior. Stop-restore the animation attribute to its initial value after the animation ends
-->
< Storyboard X: Name = "Storyboard" >
< Pointanimation Storyboard. targetname = "Ellipse" Storyboard. targetproperty = "Center" Begintime = "00:00:00" From = "50, 50" To = "300,500" Duration = "0: 3" Autoreverse = "True" Repeatbehavior = "3x" Fillbehavior = "Stop" >
</ Pointanimation >
</ Storyboard >
</ Stackpanel. Resources >
</ Stackpanel >
</ Usercontrol >
C #
Using System;
Using System. Collections. Generic;
Using System. LINQ;
Using System. net;
Using System. windows;
Using System. Windows. controls;
Using System. Windows. documents;
Using System. Windows. input;
Using System. Windows. Media;
Using System. Windows. Media. animation;
Using System. Windows. shapes;
NamespaceSilverlight. Common
{
Public Partial ClassTest: usercontrol
{
PublicTest ()
{
Initializecomponent ();
}
Private Void Button_click ( Object Sender, routedeventargs e ){
Storyboard. Begin ();
}
Private Void Button_click_1 ( Object Sender, routedeventargs e ){
Storyboard. Pause ();
}
Private Void Button_click_2 ( Object Sender, routedeventargs e ){
Storyboard. Resume ();
}
Private Void Button_click_3 ( Object Sender, routedeventargs e ){
Storyboard. Stop ();
}
}
}