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 .../>  
...  

Type> AnimationUsingKeyFrames 的 < 範例包括 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>   
...  

備註

時程表的簡單持續時間會構成單一向前反復專案與總播放時間的時間,包括重複。

預設持續時間行為

具有 值 AutomaticDuration 結構的行為取決於時間軸的類型:

時間表 行為
Timeline 未決定的 (Timeline 是抽象)
ParallelTimeline,

Storyboard,

TimelineGroup
展開以符合子時間軸
<類型>動畫 (稱為「From/To/By」或「基本」動畫) 1 秒
<類型>AnimationUsingKeyFrames (稱為主要畫面格動畫) 所有主要畫面格 KeyTime 值的總和

相依性屬性資訊

識別碼欄位 DurationProperty
中繼資料屬性設定為 true

適用於

另請參閱