Timeline.BeginTime Proprietà

Definizione

Ottiene o imposta l'ora in cui deve iniziare questa 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)

Valore della proprietà

Ora in cui deve iniziare questa Timeline, relativa a BeginTime dell'entità principale. Se si tratta di una sequenza temporale radice, l'ora è relativa al momento di avvio interattivo (il momento in cui la sequenza temporale è stata attivata). Questo valore può essere positivo, negativo o null. Un valore null indica che la sequenza temporale non viene mai riprodotta. Il valore predefinito è zero.

Esempio

La proprietà di BeginTime una sequenza temporale determina l'inizio del periodo attivo di una sequenza temporale. Se la sequenza temporale ha una sequenza temporale padre, la BeginTime proprietà determina il tempo necessario per l'avvio della sequenza temporale dopo l'avvio dell'elemento padre. Se la sequenza temporale è una sequenza temporale radice ( Storyboardad esempio , ad esempio), la BeginTime proprietà determina il tempo impiegato dalla sequenza temporale per iniziare la riproduzione dopo l'attivazione.

L'esempio seguente mostra diverse sequenze temporali con impostazioni diverse 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>

Commenti

La BeginTime proprietà è utile per la creazione di sequenze temporali che giocano in una sequenza: aumentando la BeginTime sequenza temporale delle sequenze successive che condividono lo stesso elemento padre, è possibile sfalsare i tempi di riproduzione.

Valori negativi

Un valore negativo BeginTime comporta il comportamento di un oggetto Timeline come se fosse iniziato in un certo momento nel passato. Ad esempio, un oggetto Timeline con un BeginTime valore negativo di 2,5 secondi e un Duration valore di 5 secondi verrà completato a metà strada all'avvio.

BeginTime e SpeedRatio

L'ora descritta dalla BeginTime proprietà viene misurata nel tempo padre della sequenza temporale. Ad esempio, una sequenza temporale con un BeginTime valore pari a 5 il cui padre ha un SpeedRatio valore pari a 2 inizia effettivamente dopo 2,5 secondi.

L'impostazione di SpeedRatio una sequenza temporale non influisce sul relativo BeginTimeoggetto . Ad esempio, una sequenza temporale con un BeginTime valore di 5 secondi, un SpeedRatio valore pari a 2 e una sequenza temporale padre con un SpeedRatio valore pari a 1 inizia dopo 5 secondi, non 2,5.

Informazioni proprietà di dipendenza

Campo Identificatore BeginTimeProperty
Proprietà dei metadati impostate su true Nessuno

Uso della sintassi XAML per gli attributi

<OggettoBeginTime =";[days.] hours:minutes:seconds[. fractionalSeconds]"/>

-oppure-

<OggettoBeginTime =";[days.] hours:minutes"/>

-oppure-

<OggettoBeginTime ="Days"/>

-oppure-

<OggettoBeginTime ="{x:Null Markup Extension}"/>

Valori XAML

Gli elementi tra parentesi quadre ([ e ]) sono facoltativi.

Giorni
System.Int32

Valore maggiore o uguale a 0 che descrive il numero di giorni trascorsi da questa ora di inizio.

Ore
System.Int32

Valore compreso tra 0 e 23 che rappresenta il numero di ore estese da questa ora di inizio.

Minuti
System.Int32

Valore compreso tra 0 e 59 che rappresenta il numero di minuti trascorsi da questa ora di inizio.

secondi
System.Int32

Valore compreso tra 0 e 59 che rappresenta il numero di secondi compresi nell'intervallo di tempo di inizio.

fractionalSeconds
System.Int32

Valore costituito da 1 a 7 cifre che rappresenta i secondi frazionari.

Per la sintassi completa TimeSpan , vedere la sezione Osservazioni della Parse pagina.

Si applica a

Vedi anche