Storyboard.Seek Method
Microsoft Silverlight will reach end of support after October 2021. Learn more.
Moves the storyboard to the specified animation position. The storyboard performs the requested seek when the next clock tick occurs.
Namespace: System.Windows.Media.Animation
Assembly: System.Windows (in System.Windows.dll)
Syntax
'Declaration
Public Sub Seek ( _
offset As TimeSpan _
)
public void Seek(
TimeSpan offset
)
Parameters
- offset
Type: System.TimeSpan
A positive or negative time value that describes the amount by which the timeline should move forward or backward from the beginning of the animation. By using the TimeSpan Parse behavior, a TimeSpan can be specified as a string in the following format (in this syntax, the [] characters denote optional components of the string, but the quotes, colons, and periods are all a literal part of the syntax):
"[days.]hours:minutes:seconds[.fractionalSeconds]"
- or -
"days"
Examples
The following example shows how to use the Seek method. When you click the rectangle created by the following XAML, the animation jumps to 3 seconds from the beginning of the animation.
<StackPanel>
<StackPanel.Resources>
<Storyboard x:Name="myStoryboard">
<DoubleAnimation
Storyboard.TargetName="MyAnimatedRectangle"
Storyboard.TargetProperty="Width"
From="50" To="550" Duration="0:0:5" />
</Storyboard>
</StackPanel.Resources>
<Rectangle
x:Name="MyAnimatedRectangle"
Width="50"
Height="100"
Fill="Blue"
MouseLeftButtonDown="SeekStoryboard"/>
</StackPanel>
Private Sub SeekStoryboard(ByVal sender As Object, ByVal e As EventArgs)
myStoryboard.Begin()
myStoryboard.Seek(New TimeSpan(0, 0, 3))
End Sub
private void SeekStoryboard(object sender, EventArgs e)
{
myStoryboard.Begin();
myStoryboard.Seek(new TimeSpan(0, 0, 3));
}
Version Information
Silverlight
Supported in: 5, 4, 3
Silverlight for Windows Phone
Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0
Platforms
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.
See Also