Timeline.BeginTime Właściwość

Definicja

Pobiera lub ustawia czas, w którym to Timeline powinno się rozpocząć.

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)

Wartość właściwości

Czas, w którym to Timeline powinno się rozpocząć, względem elementu nadrzędnego BeginTime. Jeśli ta oś czasu jest osią czasu głównego, czas jest względny względem interakcyjnego czasu rozpoczęcia (moment wyzwolenia osi czasu). Ta wartość może być dodatnia, ujemna null lub null; wartość oznacza, że oś czasu nigdy nie jest odtwarzana. Wartość domyślna to zero.

Przykłady

Właściwość osi czasu BeginTime określa początek aktywnego okresu osi czasu. Jeśli oś czasu ma oś czasu nadrzędną, BeginTime właściwość określa czas rozpoczęcia osi czasu po uruchomieniu elementu nadrzędnego. Jeśli oś czasu jest osią czasu głównego ( Storyboardna przykład , ), BeginTime właściwość określa czas rozpoczęcia odtwarzania osi czasu po wyzwoleniu.

W poniższym przykładzie przedstawiono kilka różnych osi czasu z różnymi BeginTime ustawieniami.

<!-- 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>

Uwagi

Właściwość jest przydatna BeginTime do tworzenia osi czasu, które są odtwarzane w sekwencji: zwiększając BeginTime kolejne osie czasu współużytkujące ten sam element nadrzędny, można zachwiać czasy odtwarzania.

Wartości ujemne

Wartość ujemna BeginTime powoduje Timeline zachowanie elementu tak, jakby zaczęło się w przeszłości. Na przykład wartość Timeline z ujemną wartością BeginTime 2,5 sekundy i Duration 5 sekund wydaje się być w połowie drogi zakończona po uruchomieniu.

BeginTime i SpeedRatio

Czas opisany przez BeginTime właściwość jest mierzony w czasie elementu nadrzędnego osi czasu. Na przykład oś czasu z wartością BeginTime 5, której element nadrzędny ma SpeedRatio wartość 2, faktycznie rozpoczyna się po 2,5 sekundy.

Własne ustawienie osi czasu SpeedRatio nie ma wpływu na jego BeginTimewartość . Na przykład oś czasu z BeginTime 5 sekundami, SpeedRatio 2 i osią czasu nadrzędnego z wartością SpeedRatio 1 rozpoczyna się po 5 sekundach, a nie 2,5.

Informacje dotyczące właściwości zależności

Pole identyfikatora BeginTimeProperty
Właściwości metadanych ustawione na true Brak

Użycie atrybutu języka XAML

<ObiektuBeginTime ="[-][days.] hours:minutes:seconds[. fractionalSeconds]"/>

-lub-

<ObiektuBeginTime ="[-][days.] hours:minutes"/>

-lub-

<ObiektuBeginTime ="[-]days"/>

-lub-

<ObiektuBeginTime ="{x:Null Rozszerzenie znaczników}"/>

Wartości XAML

Elementy w nawiasach kwadratowych ([ i ]) są opcjonalne.

Dni
System.Int32

Wartość większa niż lub równa 0, która opisuje liczbę dni, które obejmują ten czas rozpoczęcia.

Godzin
System.Int32

Wartość z zakresu od 0 do 23, która reprezentuje liczbę godzin obejmujących ten czas rozpoczęcia.

Minut
System.Int32

Wartość z zakresu od 0 do 59, która reprezentuje liczbę minut, które obejmują ten czas rozpoczęcia.

Sekund
System.Int32

Wartość z zakresu od 0 do 59, która reprezentuje liczbę sekund w tym czasie rozpoczęcia.

ułamkoweSekundy
System.Int32

Wartość składająca się z od 1 do 7 cyfr, która reprezentuje sekundy ułamkowe.

Aby uzyskać pełną TimeSpan składnię, zobacz sekcję Uwagi na Parse stronie.

Dotyczy

Zobacz też