次の方法で共有


Timeline.BeginTime プロパティ

定義

この Timeline を開始する時刻を取得または設定します。

public:
 property Nullable<TimeSpan> BeginTime { Nullable<TimeSpan> get(); void set(Nullable<TimeSpan> value); };
public TimeSpan? BeginTime { get; set; }
member this.BeginTime : Nullable<TimeSpan> with get, set
Public Property BeginTime As Nullable(Of TimeSpan)

プロパティ値

親の BeginTimeを基準にして、この Timeline を開始する時刻。 このタイムラインがルート タイムラインの場合、時間は対話型の開始時刻 (タイムラインがトリガーされた時点) を基準とします。 この値は、正、負、または null可能性があります。null 値は、タイムラインが再生されないという意味です。 既定値は 0 です。

タイムラインの BeginTime プロパティは、タイムラインのアクティブ期間の開始を決定します。 タイムラインに親タイムラインがある場合、BeginTime プロパティは、タイムラインが親の開始後に開始されるまでの時間を決定します。 タイムラインがルート タイムライン (Storyboardなど) の場合、BeginTime プロパティは、タイムラインがトリガーされた後に再生を開始するのにかかる時間を決定します。

次の例は、異なる BeginTime 設定を持つ複数の異なるタイムラインを示しています。

<!-- This example shows how the BeginTime property determines when a timeline starts.
     Several rectangles are animated by DoubleAnimations with identical 
     durations and target values, but with different
     BeginTime settings. -->
     
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  WindowTitle="BeginTime Example">
  <StackPanel Margin="20">

    <!-- The rectangles to animate. -->
    <Rectangle Name="DefaultBeginTimeRectangle" 
      Width="20" Height="20" Fill="Blue"  />
      
    <Rectangle Name="DelayedBeginTimeRectangle" 
      Width="20" Height="20" Fill="Blue"  />
    
    <Rectangle Name="DelayedAnimationWithDelayedParentRectangle" 
      Width="20" Height="20" Fill="Blue"  /> 

    <Rectangle Name="NegativeBeginTimeExampleRectangle" 
      Width="20" Height="20" Fill="Blue"  />            
    
    <!-- Create a button to start the animations. -->
    <Button Margin="20" Content="Start Animations">
      <Button.Triggers>
        <EventTrigger RoutedEvent="Button.Click">
          <BeginStoryboard>
            <Storyboard>

              <!-- This animation starts as soon as the button is clicked, because it
                   has a BeginTime of 0. -->
              <DoubleAnimation 
                Storyboard.TargetName="DefaultBeginTimeRectangle" 
                Storyboard.TargetProperty="Width"
                BeginTime="0:0:0" From="100" To="600" Duration="0:0:5"  /> 

              <!-- This animation starts 5 seconds after the button is clicked. -->
              <DoubleAnimation 
                Storyboard.TargetName="DelayedBeginTimeRectangle" 
                Storyboard.TargetProperty="Width"  
                BeginTime="0:0:5" From="100" To="600" Duration="0:0:5" />
                
              <ParallelTimeline BeginTime="0:0:5">  

              <!-- This animation starts 10 seconds after the button is clicked, 
                   because its parent has a BeginTime of 5 seconds and it has
                   a BeginTime of 5 seconds: 5 + 5 = 10.  -->              
                <DoubleAnimation  
                  Storyboard.TargetName="DelayedAnimationWithDelayedParentRectangle" 
                  Storyboard.TargetProperty="Width" 
                  BeginTime="0:0:5" From="100" To="600" Duration="0:0:5"  />
              </ParallelTimeline>
              
              <!-- This animation starts as soon as the button is clicked, but
                   it animates from 350 to 600 instead of from 100 to 600 
                   because of its negative BeginTime. The negative BeginTime
                   setting advances the animation, so that it behaves as though
                   it had already been playing for 2.5 seconds as soon as it is
                   started. -->
              <DoubleAnimation 
                Storyboard.TargetName="NegativeBeginTimeExampleRectangle" 
                Storyboard.TargetProperty="Width"  
                BeginTime="-0:0:2.5" From="100" To="600" Duration="0:0:5" />              
              
            </Storyboard>
          </BeginStoryboard>
        </EventTrigger>
      </Button.Triggers>      
    </Button>
    
    <!-- This example demonstrates how the BeginTime property works on a root timeline. -->
    <Rectangle Name="RootTimelineWithDelayedBeginTimeRectangle"
      Width="20" Height="20" Fill="Blue" >
      <Rectangle.Triggers>
        <EventTrigger RoutedEvent="Rectangle.MouseLeftButtonDown">
          <BeginStoryboard>
            <Storyboard BeginTime="0:0:5">
            
              <!-- This animation starts 5 seconds after the left mouse button
                   is pressed, because its parent storyboard (a root timeline)
                   has a BeginTime of 5 seconds. -->
              <DoubleAnimation 
                Storyboard.TargetName="RootTimelineWithDelayedBeginTimeRectangle" 
                Storyboard.TargetProperty="Width"
                BeginTime="0:0:0" From="100" To="600" Duration="0:0:2" />
            </Storyboard>
          </BeginStoryboard>
        </EventTrigger>
      </Rectangle.Triggers>
    </Rectangle>    
  </StackPanel>
</Page>

注釈

BeginTime プロパティは、シーケンスで再生されるタイムラインを作成する場合に便利です。同じ親を共有する連続するタイムラインの BeginTime を増やすことで、再生時間をずらすことができます。

負の値

負の BeginTime 値を指定すると、Timeline は過去のある時点で開始されたかのように動作します。 たとえば、BeginTime が負の 2.5 秒で、Duration が 5 秒の Timeline は、開始時に途中で終了しているように見えます。

BeginTime と SpeedRatio

BeginTime プロパティによって記述される時間は、タイムラインの親の時刻で測定されます。 たとえば、BeginTime が 5 で、親の SpeedRatio が 2 であるタイムラインは、実際には 2.5 秒後に開始されます。

タイムライン独自の SpeedRatio 設定は、その BeginTimeには影響しません。 たとえば、BeginTime が 5 秒、SpeedRatio が 2、親タイムラインの SpeedRatio が 1 のタイムラインは、2.5 ではなく 5 秒後に開始されます。

依存関係プロパティ情報

識別子フィールド BeginTimeProperty
true に設定されたメタデータ プロパティ 何一つ

XAML 属性の使用法

< オブジェクトBeginTime="[-][.]時間::[.分秒]"/>

-又は-

< オブジェクトBeginTime="[-][.]時間:"/>

-又は-

< オブジェクトBeginTime="[-]"/>

-又は-

< オブジェクトBeginTime="{x:Null マークアップ拡張}"/>

XAML 値

角かっこ ([ および ]) の項目は省略可能です。


System.Int32

この開始時刻にまたがっている日数を表す 0 以上の値。

時間
System.Int32

この開始時刻に及ぶ時間数を表す 0 ~ 23 の値。


System.Int32

この開始時刻までの分数を表す 0 ~ 59 の値。


System.Int32

この開始時刻までの秒数を表す 0 ~ 59 の値。

fractionalSeconds
System.Int32

秒の小数部を表す 1 ~ 7 桁の数字で構成される値。

完全な TimeSpan 構文については、「Parse」ページの「解説」セクションを参照してください。

適用対象

こちらもご覧ください