Condividi tramite


KeyTime Structure

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Specifies when a particular key frame should take place during an animation.

Namespace:  System.Windows.Media.Animation
Assembly:  System.Windows (in System.Windows.dll)

Syntax

'Declaration
Public Structure KeyTime
public struct KeyTime
<object property="[days.]hours:minutes:seconds[.fractionalSeconds]"/>

XAML Values

  • days
    Optional. An integer value greater than or equal to 0 that specifies the number of days.

  • hours
    Required, even if 0. An integer value between 0 and 23 that specifies the number of hours.

  • minutes
    Optional if only hours are desired, but needs to be at least set to 0 if you intend to set a seconds value. An integer value between 0 and 59 that specifies the number of minutes.

  • seconds
    Optional if only hours/minutes are desired. An integer value between 0 and 59 that specifies the number of seconds.

  • fractionalSeconds
    Optional. A value consisting of 1 to 7 digits of decimal precision that specifies fractional seconds.

The KeyTime type exposes the following members.

Properties

  Name Description
Public propertySupported by Silverlight for Windows Phone TimeSpan Gets the time when the key frame ends, expressed as a time relative to the beginning of the animation.
Public propertySupported by Silverlight for Windows Phone Type Gets the KeyTimeType value this instance represents.
Public propertyStatic memberSupported by Silverlight for Windows Phone Uniform Gets a uniform value, which divides the allotted time of the animation evenly between key frames.

Top

Methods

  Name Description
Public methodSupported by Silverlight for Windows Phone Equals(KeyTime) Indicates whether a specified KeyTime is equal to this KeyTime.
Public methodSupported by Silverlight for Windows Phone Equals(Object) Indicates whether a KeyTime is equal to this KeyTime. (Overrides ValueType.Equals(Object).)
Public methodStatic memberSupported by Silverlight for Windows Phone Equals(KeyTime, KeyTime) Indicates whether two KeyTime values are equal.
Protected methodSupported by Silverlight for Windows Phone Finalize Allows an object to try to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.)
Public methodStatic memberSupported by Silverlight for Windows Phone FromTimeSpan Creates a new KeyTime, using the supplied TimeSpan.
Public methodSupported by Silverlight for Windows Phone GetHashCode Returns a hash code representing this KeyTime. (Overrides ValueType.GetHashCode().)
Public methodSupported by Silverlight for Windows Phone GetType Gets the Type of the current instance. (Inherited from Object.)
Protected methodSupported by Silverlight for Windows Phone MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Public methodSupported by Silverlight for Windows Phone ToString Returns a string representation of this KeyTime. (Overrides ValueType.ToString().)

Top

Operators

  Name Description
Public operatorStatic memberSupported by Silverlight for Windows Phone Equality Compares two KeyTime values for equality.
Public operatorStatic memberSupported by Silverlight for Windows Phone Implicit(TimeSpan to KeyTime) Implicitly converts a TimeSpan to a KeyTime.
Public operatorStatic memberSupported by Silverlight for Windows Phone Inequality Compares two KeyTime values for inequality.

Top

Remarks

Each key frame's KeyTime specifies when that key frame ends. It does not specify how long the key frame plays. The amount of time a key frame plays is determined by when the key frame ends, when the previous key frame ended, and the animation's duration. See Key-Frame Animations for more information.

In WPF, a KeyTime can be specified using several formats, including a uniform or paced key system. In Silverlight 5, a KeyTime can only specify a TimeSpan.

Specifying a KeyTime by only an integer without any time span literal characters such as : or . will result in a KeyTime of that number of days! This is seldom the intended result. Usually you specify time spans in seconds. As such, the KeyTime string must include preceding zero values for hours and minutes, along with the appropriate literal : characters as separators between hours, minutes, and seconds. For instance, to specify a KeyTime of five seconds, the KeyTime string would be 0:0:5 (0:0:05 is equivalent).

Object element usage in XAML is possible but has no practical usage. You cannot declare a KeyTime as a usable, shareable object in a ResourceDictionary.

JavaScript API Notes

Creating a KeyTime in the JavaScript API is only possible through a type conversion syntax when setting a property such as KeyTime that takes a KeyTime, with the value specified as a string interpreted by the same grammar as the XAML usage. In managed code, you can create a KeyTime using the constructors.

In the XAML usage, [] indicates optional values; the [] are not literals. The : (colon) and . (period) characters are both literals, and delimit the h:m:s string form of a common time span, or the optional days and fractionalSeconds values.

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.

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.