Språk

Timeline.BeginTime Egenskap

Definition

Hämtar eller anger den tid då detta Timeline ska börja.

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)

Egenskapsvärde

Den tid då detta Timeline ska börja, i förhållande till dess överordnade BeginTime. Om den här tidslinjen är en rottidslinje är tiden relativ till dess interaktiva starttid (det ögonblick då tidslinjen utlöstes). Det här värdet kan vara positivt, negativt eller null; ett null värde innebär att tidslinjen aldrig spelas upp. Standardvärdet är noll.

Exempel

En tidslinjes BeginTime egenskap avgör början av en tidslinjes aktiva period. Om tidslinjen har en överordnad tidslinje avgör egenskapen BeginTime hur lång tid det tar för tidslinjen att starta efter att dess överordnade start. Om tidslinjen är en rottidslinje (till exempel Storyboard en BeginTime) avgör egenskapen hur lång tid tidslinjen tar att börja spelas upp när den har utlösts.

I följande exempel visas flera olika tidslinjer med olika BeginTime inställningar.

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

Kommentarer

Egenskapen BeginTime är användbar för att skapa tidslinjer som spelas upp i en sekvens: genom att öka BeginTime antalet efterföljande tidslinjer som delar samma överordnade kan du fördela deras uppspelningstider.

Negativa värden

Ett negativt BeginTime värde gör att ett Timeline beter sig som om det startade någon gång tidigare. Till exempel ser en Timeline med negativa BeginTime 2,5 sekunder och en Duration på 5 sekunder ut att vara halvvägs klar när den startar.

BeginTime och SpeedRatio

Den tid som beskrivs av egenskapen BeginTime mäts i tidslinjens överordnade tid. Till exempel startar en tidslinje med en BeginTime av 5 vars överordnade har en SpeedRatio på 2 faktiskt efter 2,5 sekunder.

En tidslinjes egen SpeedRatio inställning påverkar inte dess BeginTime. Till exempel startar en tidslinje med BeginTime 5 sekunder, en SpeedRatio av 2 och en överordnad tidslinje med en SpeedRatio på 1 efter 5 sekunder, inte 2,5.

Information om beroendeegenskap

Objekt Value
Identifierarfält BeginTimeProperty
Metadataegenskaper inställda på true Ingen

XAML-attributanvändning

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

-eller-

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

-eller-

< ObjektBeginTime="[-]days"/>

-eller-

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

XAML-värden

Objekt inom hakparenteser ([ och ]) är valfria.

DagarSystem.Int32

Ett värde som är större än eller lika med 0 som beskriver antalet dagar som sträcker sig över den här starttiden.

TimmarSystem.Int32

Ett värde mellan 0 och 23 som representerar antalet timmar som sträcker sig över den här starttiden.

MinuterSystem.Int32

Ett värde mellan 0 och 59 som representerar antalet minuter som sträcker sig över den här starttiden.

SekunderSystem.Int32

Ett värde mellan 0 och 59 som representerar antalet sekunder som sträcker sig över den här starttiden.

fractionalSecondsSystem.Int32

Ett värde som består av 1 till 7 siffror som representerar bråksekunder.

TimeSpan Fullständig syntax finns i avsnittet Kommentarer på Parse sidan.

Gäller för

Se även