Timeline.Duration 属性

定义

获取或设置此时间线播放的时间长度,而不是计数重复。

public:
 property System::Windows::Duration Duration { System::Windows::Duration get(); void set(System::Windows::Duration value); };
public System.Windows.Duration Duration { get; set; }
member this.Duration : System.Windows.Duration with get, set
Public Property Duration As Duration

属性值

时间线的简单持续时间:此时间线完成一次向前迭代所花费的时间。 默认值是 Automatic

示例

ParallelTimelineStoryboard 是对象的类型 TimelineGroup 。 的 TimelineGroup 持续时间由其子时间线的持续时间决定。 例如, Storyboard 以下将运行 6 秒 (持续时间为 6 秒) ,因为这是其最后一个子时间线 (DoubleAnimation) 结束的时间。

注意

注意:以下示例中省略了代码,这些示例仅用于说明目的。

[xaml]

...  
  <Storyboard>  
    <DoubleAnimation Duration="0:0:2" …/>  
    <DoubleAnimation Duration="0:0:4" BeginTime="0:0:2" …/>  
  </Storyboard>   
...  

<类型>动画的示例包括 DoubleAnimationPointAnimationColorAnimation等。Duration如果未为这些类型的动画指定任何内容,它们将运行一秒钟。

[xaml]

...  
  <!-- With no Duration specified, this animation will run for   
       one second -->  
  <DoubleAnimation .../>  
...  

<类型>AnimationUsingKeyFrame 的示例包括 DoubleAnimationUsingKeyFramesPointAnimationUsingKeyFrames等。如果未为这些类型的动画指定任何Duration内容,则它们将一直运行,直到所有关键帧完成。

[xaml]

...  
  <Storyboard>  

    <!-- This key frame animation will end at 4.5 seconds  
         Because that is when its last KeyFrame KeyTime ends. -->  
    <DoubleAnimationUsingKeyFrames ...>  
      <LinearDoubleKeyFrame ... KeyTime="0:0:3" />  
      <DiscreteDoubleKeyFrame ... KeyTime="0:0:3.5" />  
      <DiscreteDoubleKeyFrame ... KeyTime="0:0:4" />  
      <DiscreteDoubleKeyFrame ... KeyTime="0:0:4.5" />  
    </DoubleAnimationUsingKeyFrames>  
  </Storyboard>   
...  

注解

时间线的简单持续时间构成单个向前迭代的时间与总播放时间(包括重复时间)。

默认持续时间行为

值为 Automatic 的结构的行为Duration取决于时间线的类型:

时间线 行为
Timeline 不确定 (Timeline 是抽象)
ParallelTimeline,

Storyboard,

TimelineGroup
展开以适应子时间线
<类型>动画 (称为“From/To/By”或“basic”动画) 1 秒
<类型>AnimationUsingKeyFrames (称为关键帧动画) 所有关键帧 KeyTime 值的总和

依赖项属性信息

标识符字段 DurationProperty
元数据属性设置为 true

适用于

另请参阅