Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

Seek

Silverlight

Moves a Storyboard object to a new position when the next clock tick occurs.

object.Seek(offset)

offset

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. The TimeSpan is specified as a string in the following format (in this syntax, the [] characters denote optional components of the string, but the quotation marks, colons, and periods are parts of the syntax):

"[days.]hours:minutes:seconds[.fractionalSeconds]"

- or -

"days"

Defining a TimeSpan is possible only through a type conversion syntax, when you set a property or call a method that takes TimeSpan as a type and specify the value as a delimited string. For more information, see the TimeSpan reference topic.

The following example shows how to use the Seek method. When you click the rectangle that is created by the XAML code, the animation jumps to 3 seconds from the beginning of the animation.

<Canvas
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  <Rectangle
    x:Name="MyAnimatedRectangle"
    Width="50"
    Height="100"
    Fill="Blue"
      MouseLeftButtonDown="SeekStoryboard"
      >
    <Rectangle.Triggers>
      <!-- Increases the width of the rectangle. -->
      <EventTrigger RoutedEvent="Rectangle.Loaded">
        <BeginStoryboard>
          <Storyboard x:Name="RectWidthStoryboard">
            <DoubleAnimation
              Storyboard.TargetName="MyAnimatedRectangle"
              Storyboard.TargetProperty="Width"
              From="50" To="550" Duration="0:0:5" />
          </Storyboard>
        </BeginStoryboard>
      </EventTrigger>
    </Rectangle.Triggers>
  </Rectangle>
</Canvas>
function SeekStoryboard(sender, eventArgs)
{

  // Get a reference to the Storyboard.
  var myStoryboard = sender.findName("RectWidthStoryboard");

  // Seek to 3 seconds after the animation begins.
  myStoryboard.Seek("0:0:3");

}

Community Additions

ADD
Show:
© 2015 Microsoft