Timeline.BeginTime Proprietà
Definizione
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.The time at which this Timeline should begin, relative to its parent's BeginTime. 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).If this timeline is a root timeline, the time is relative to its interactive begin time (the moment at which the timeline was triggered). Questo valore può essere positivo, negativo o null
. Un valore null
indica che la sequenza temporale non viene mai riprodotta.This value may be positive, negative, or null
; a null
value means the timeline never plays. Il valore predefinito è zero.The default value is zero.
Esempio
La proprietà di una sequenza temporale BeginTime determina l'inizio del periodo attivo di una sequenza temporale.A timeline's BeginTime property determines the beginning of a timeline's active period. Se la sequenza temporale ha una sequenza temporale padre, la BeginTime proprietà determina per quanto tempo la sequenza temporale deve essere avviata dopo l'avvio del padre.If the timeline has a parent timeline, the BeginTime property determines how long it takes the timeline to start after its parent starts. Se la sequenza temporale è una sequenza temporale radice ( Storyboard ad esempio), la BeginTime proprietà determina per quanto tempo la sequenza temporale impiega per iniziare la riproduzione dopo che è stata attivata.If the timeline is a root timeline (a Storyboard, for example), the BeginTime property determines how long the timeline takes to start playing after it is triggered.
Nell'esempio riportato di seguito vengono illustrate diverse sequenze temporali con BeginTime impostazioni diverse.The following example shows several different timelines with different BeginTime settings.
<!-- 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 riprodotte in una sequenza: aumentando la BeginTime delle sequenze temporali successive che condividono lo stesso elemento padre, è possibile scaglionare i tempi di riproduzione.The BeginTime property is useful for creating timelines that play in a sequence: by increasing the BeginTime of successive timelines that share the same parent, you can stagger their play times.
Valori negativiNegative Values
Un BeginTime valore negativo causa un Timeline comportamento come se fosse avviato in un determinato momento nel passato.A negative BeginTime value causes a Timeline to behave as though it started at some time in the past. Ad esempio, un oggetto Timeline con un valore BeginTime di 2,5 secondi negativi e un valore Duration di 5 secondi avrà un aspetto a metà strada al termine dell'avvio.For example, a Timeline with a BeginTime of negative 2.5 seconds and a Duration of 5 seconds will appear to be half-way finished when it starts.
BeginTime e SpeedRatioBeginTime and SpeedRatio
Il tempo descritto dalla BeginTime proprietà viene misurato nel tempo parent's della sequenza temporale.The time described by the BeginTime property is measured in the timeline's parent's time. Ad esempio, una sequenza temporale con un valore pari a 5, il BeginTime cui elemento padre ha un valore SpeedRatio di 2, inizia effettivamente dopo 2,5 secondi.For example, a timeline with a BeginTime of 5 whose parent has a SpeedRatio of 2 actually starts after 2.5 seconds.
L'impostazione di una sequenza temporale SpeedRatio non influisce sui relativi BeginTime .A timeline's own SpeedRatio setting does not affect its BeginTime. Ad esempio, una sequenza temporale con un valore BeginTime di 5 secondi, un SpeedRatio di 2 e una sequenza temporale padre con un valore SpeedRatio di 1 viene avviata dopo 5 secondi, non 2,5.For example, a timeline with a BeginTime of 5 seconds, a SpeedRatio of 2, and a parent timeline with a SpeedRatio of 1 starts after 5 seconds, not 2.5.
Informazioni proprietà di dipendenzaDependency Property Information
Campo identificatoreIdentifier field | BeginTimeProperty |
Proprietà dei metadati impostate su true Metadata properties set to true |
NessunoNone |
Uso della sintassi XAML per gli attributiXAML Attribute Usage
<object BeginTime= "[-] [giorni.] ore:minuti:secondi[.* fractionalSeconds*] "/><object BeginTime="[-][days.]hours:minutes:seconds[.fractionalSeconds]"/>
-oppure--or-
<object BeginTime= "[-] [giorni.] ore:minuti"/><object BeginTime="[-][days.]hours:minutes"/>
-oppure--or-
<object BeginTime= "[-]giorni"/><object BeginTime="[-]days"/>
-oppure--or-
<object BeginTime= "{X:Null Markup Extension}"/><object BeginTime="{x:Null Markup Extension}"/>
Valori XAMLXAML Values
Gli elementi tra parentesi quadre ( [
e ]
) sono facoltativi.Items in square brackets ([
and ]
) are optional.
giornidays
System.Int32
Valore maggiore o uguale a 0 che descrive il numero di giorni estesi da questa ora di inizio.A value greater than or equal to 0 that describes the number of days spanned by this begin time.
orehours
System.Int32
Valore compreso tra 0 e 23 che rappresenta il numero di ore estesi da questa ora di inizio.A value between 0 and 23 that represents the number of hours spanned by this begin time.
minutiminutes
System.Int32
Valore compreso tra 0 e 59 che rappresenta il numero di minuti estesi da questa ora di inizio.A value between 0 and 59 that represents the number of minutes spanned by this begin time.
secondiseconds
System.Int32
Valore compreso tra 0 e 59 che rappresenta il numero di secondi estesi da questa ora di inizio.A value between 0 and 59 that represents the number of seconds spanned by this begin time.
fractionalSecondsfractionalSeconds
System.Int32
Valore composto da 1 a 7 cifre che rappresenta i secondi frazionari.A value consisting of 1 to 7 digits that represents fractional seconds.
Per la TimeSpan sintassi completa, vedere la sezione Osservazioni della Parse pagina.For the complete TimeSpan syntax, see the Remarks section of the Parse page.