Timeline.BeginTime Propriedade

Definição

Define ou define a hora em que isto Timeline deve começar.

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)

Valor de Propriedade

O momento em que isto Timeline deve começar, relativamente ao do seu progenitor BeginTime. Se esta linha temporal for uma linha temporal raiz, o tempo é relativo ao seu início interativo (o momento em que a linha temporal foi ativada). Este valor pode ser positivo, negativo ou null; um null valor significa que a linha temporal nunca se joga. O valor padrão é zero.

Exemplos

A propriedade de BeginTime uma linha temporal determina o início do período ativo de uma linha temporal. Se a linha temporal tiver uma linha temporal principal, a BeginTime propriedade determina quanto tempo demora a começar a linha temporal depois do início do pai. Se a linha temporal for uma linha temporal raiz (um Storyboard, por exemplo), a BeginTime propriedade determina quanto tempo a linha temporal demora a começar a ser reproduzida depois de ser ativada.

O exemplo seguinte mostra várias linhas temporais diferentes com diferentes BeginTime cenários.

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

Observações

A BeginTime propriedade é útil para criar linhas temporais que se jogam numa sequência: ao aumentar o número BeginTime de linhas temporais sucessivas que partilham o mesmo pai, podes escalonar os seus tempos de jogo.

Valores negativos

Um valor negativo BeginTime faz com que a Timeline se comporte como se tivesse começado em algum momento do passado. Por exemplo, a Timeline com a BeginTime de menos 2,5 segundos e a Duration de 5 segundos parecerá estar a meio do fim quando começa.

InícioTempo e SpeedRatio

O tempo descrito pela BeginTime propriedade é medido no tempo do pai da linha temporal. Por exemplo, uma linha temporal com a BeginTime de 5 cujo progenitor tem a SpeedRatio de 2 começa na verdade após 2,5 segundos.

O próprio SpeedRatio cenário de uma linha temporal não afeta o seu BeginTime. Por exemplo, uma linha temporal com a BeginTime de 5 segundos, a SpeedRatio de 2 e uma linha temporal principal com a SpeedRatio de 1 começa após 5 segundos, não 2,5.

Informação de Propriedade de Dependência

Iteme Value
Campo identificador BeginTimeProperty
Propriedades dos metadados definidas como true None

Uso de atributos XAML

< ObjetoBeginTime="[-][dias.]horas:minutos:segundos[.fractionalSeconds]"/>

-ou-

< ObjetoBeginTime="[-][dias.]horas:minutos"/>

-ou-

< ObjetoBeginTime="[-]dias"/>

-ou-

< ObjetoBeginTime="{x:Extensão de Marcação Nula}"/>

Valores XAML

Os itens entre parênteses quadrados ([ e ]) são opcionais.

DiasSystem.Int32

Um valor maior ou igual a 0 que descreve o número de dias decorridos por este tempo de início.

HorárioSystem.Int32

Um valor entre 0 e 23 que representa o número de horas decorridas por este tempo de início.

AtaSystem.Int32

Um valor entre 0 e 59 que representa o número de minutos decorridos por este tempo de início.

segundosSystem.Int32

Um valor entre 0 e 59 que representa o número de segundos decorridos por este tempo de início.

fractionalSecondsSystem.Int32

Um valor composto por 1 a 7 dígitos que representa frações de segundo.

Para a sintaxe completa TimeSpan , veja a secção Observações da Parse página.

Aplica-se a

Ver também