FrameworkElement.BeginStoryboard FrameworkElement.BeginStoryboard FrameworkElement.BeginStoryboard Method

定義

開始提供之腳本中包含的動作順序。Begins the sequence of actions contained in the provided storyboard.

多載

BeginStoryboard(Storyboard) BeginStoryboard(Storyboard) BeginStoryboard(Storyboard)

開始提供之腳本中包含的動作順序。Begins the sequence of actions that are contained in the provided storyboard.

BeginStoryboard(Storyboard, HandoffBehavior) BeginStoryboard(Storyboard, HandoffBehavior) BeginStoryboard(Storyboard, HandoffBehavior)

使用若屬性已經顯示動畫時應發生之情形的指定選項,開始提供之腳本中包含的動作順序。Begins the sequence of actions contained in the provided storyboard, with options specified for what should happen if the property is already animated.

BeginStoryboard(Storyboard, HandoffBehavior, Boolean) BeginStoryboard(Storyboard, HandoffBehavior, Boolean) BeginStoryboard(Storyboard, HandoffBehavior, Boolean)

使用控制啟動後之動畫的指定狀態,開始提供之腳本中包含的動作順序。Begins the sequence of actions contained in the provided storyboard, with specified state for control of the animation after it is started.

BeginStoryboard(Storyboard) BeginStoryboard(Storyboard) BeginStoryboard(Storyboard)

開始提供之腳本中包含的動作順序。Begins the sequence of actions that are contained in the provided storyboard.

public:
 void BeginStoryboard(System::Windows::Media::Animation::Storyboard ^ storyboard);
public void BeginStoryboard (System.Windows.Media.Animation.Storyboard storyboard);
member this.BeginStoryboard : System.Windows.Media.Animation.Storyboard -> unit

參數

storyboard
Storyboard Storyboard Storyboard

要開始的腳本。The storyboard to begin.

範例

下列範例會擷取Storyboard從 [資源],然後執行,Storyboard內部事件時處理的類別。The following example retrieves a Storyboard from resources, and then runs that Storyboard when an internal event is class handled.

private void OnImage1Animate(object sender, RoutedEventArgs e)
{
    Storyboard s;

    s = (Storyboard)this.FindResource("RotateStoryboard");
    this.BeginStoryboard(s);
}
Private Sub OnImage1Animate(ByVal sender As Object, ByVal e As RoutedEventArgs)
	Dim s As Storyboard

	s = CType(Me.FindResource("RotateStoryboard"), Storyboard)
	Me.BeginStoryboard(s)
End Sub

備註

最常見的動畫案例不會使用這個方法。Most typical animation scenarios do not use this method. 通常您會建立Storyboard或是BeginStoryboard項目在標記中,然後將這些稱為EventTrigger內容項目上。Typically, you create the Storyboard or BeginStoryboard element in markup, and then you place these as the EventTrigger content on an element. 事件所觸發,動畫就會執行。When triggered by the event, the animation then runs. 大部分的控制層面的Storyboard可以解決會在標記中公開的屬性。Most of the control aspects of a Storyboard can be addressed by properties that are exposed in markup.

請勿使用簽章isControllable,參數,或指定該參數時false,當動畫到達"Fill"期間,會移除相關聯的動畫的時刻表時鐘。For the signatures that do not use the isControllable, parameter, or when that parameter is specified false, the timeline clocks that are associated with the animation are removed as soon as the animation reaches the "Fill" period. 因此動畫無法重新啟動之後執行一次。Therefore the animation cannot be restarted after running once. 控制動畫也必須具備的分鏡腳本X:name 指示詞或可供程式碼中參考。Controlling an animation also requires that the storyboard have an x:Name Directive or be accessible by reference in code.

BeginStoryboard(Storyboard, HandoffBehavior) BeginStoryboard(Storyboard, HandoffBehavior) BeginStoryboard(Storyboard, HandoffBehavior)

使用若屬性已經顯示動畫時應發生之情形的指定選項,開始提供之腳本中包含的動作順序。Begins the sequence of actions contained in the provided storyboard, with options specified for what should happen if the property is already animated.

public:
 void BeginStoryboard(System::Windows::Media::Animation::Storyboard ^ storyboard, System::Windows::Media::Animation::HandoffBehavior handoffBehavior);
public void BeginStoryboard (System.Windows.Media.Animation.Storyboard storyboard, System.Windows.Media.Animation.HandoffBehavior handoffBehavior);
member this.BeginStoryboard : System.Windows.Media.Animation.Storyboard * System.Windows.Media.Animation.HandoffBehavior -> unit

參數

storyboard
Storyboard Storyboard Storyboard

要開始的腳本。The storyboard to begin.

handoffBehavior
HandoffBehavior HandoffBehavior HandoffBehavior

列舉型別的值,其描述若腳本中描述的屬性已顯示動畫時,所要使用的行為。A value of the enumeration that describes behavior to use if a property described in the storyboard is already animated.

範例

下列範例會擷取Storyboard從 [資源],然後執行,Storyboard內部事件時處理的類別。The following example retrieves a Storyboard from resources, and then runs that Storyboard when an internal event is class handled.

private void OnImage1Animate(object sender, RoutedEventArgs e)
{
    Storyboard s;

    s = (Storyboard)this.FindResource("RotateStoryboard");
    this.BeginStoryboard(s);
}
Private Sub OnImage1Animate(ByVal sender As Object, ByVal e As RoutedEventArgs)
	Dim s As Storyboard

	s = CType(Me.FindResource("RotateStoryboard"), Storyboard)
	Me.BeginStoryboard(s)
End Sub

備註

最常見的動畫案例不會使用這個方法。Most typical animation scenarios do not use this method. 通常您會建立Storyboard或是BeginStoryboard項目在標記中,然後將這些稱為EventTrigger內容項目上。Typically, you create the Storyboard or BeginStoryboard element in markup, and then you place these as the EventTrigger content on an element. 事件所觸發,動畫就會執行。When triggered by the event, the animation then runs. 大部分的控制層面的Storyboard可以解決會在標記中公開的屬性。Most of the control aspects of a Storyboard can be addressed by properties that are exposed in markup.

請勿使用簽章isControllable,參數,或指定該參數時false,當動畫到達"Fill"期間,會移除相關聯的動畫的時刻表時鐘。For the signatures that do not use the isControllable, parameter, or when that parameter is specified false, the timeline clocks that are associated with the animation are removed as soon as the animation reaches the "Fill" period. 因此動畫無法重新啟動之後執行一次。Therefore the animation cannot be restarted after running once. 控制動畫也必須具備的分鏡腳本X:name 指示詞或可供程式碼中參考。Controlling an animation also requires that the storyboard have an x:Name Directive or be accessible by reference in code.

遞移式行為可將指定的屬性為BeginStoryboardHandoff behavior can be specified as an attribute of BeginStoryboard.

使用 Compose HandoffBehaviorUsing the Compose HandoffBehavior

當您套用StoryboardAnimationTimeline,或AnimationClock屬性,以使用Compose HandoffBehavior、 任何Clock先前該屬性相關聯的物件會繼續耗用系統資源,計時系統會執行不會自動移除時鐘。When you apply a Storyboard, AnimationTimeline, or AnimationClock to a property by using the Compose HandoffBehavior, any Clock objects previously associated with that property continue to consume system resources; the timing system does not remove the clocks automatically.

若要避免發生效能問題,當您藉由套用大量時鐘Compose,完成之後,您應該從動畫屬性移除組成的時鐘。To avoid performance issues when you apply a large number of clocks by using Compose, you should remove composing clocks from the animated property after they complete. 有數種方式可移除時鐘:There are several ways to remove a clock:

這主要是在存留期較長的物件才會發生的動畫問題。This is primarily an issue for animations on objects that have a long lifetime. 回收物件時,其時鐘也會中斷連接,並進行記憶體回收。When an object is garbage collected, its clocks are also disconnected and garbage collected.

如需時鐘物件的詳細資訊,請參閱動畫和計時系統概觀For more information about clock objects, see Animation and Timing System Overview.

BeginStoryboard(Storyboard, HandoffBehavior, Boolean) BeginStoryboard(Storyboard, HandoffBehavior, Boolean) BeginStoryboard(Storyboard, HandoffBehavior, Boolean)

使用控制啟動後之動畫的指定狀態,開始提供之腳本中包含的動作順序。Begins the sequence of actions contained in the provided storyboard, with specified state for control of the animation after it is started.

public:
 void BeginStoryboard(System::Windows::Media::Animation::Storyboard ^ storyboard, System::Windows::Media::Animation::HandoffBehavior handoffBehavior, bool isControllable);
public void BeginStoryboard (System.Windows.Media.Animation.Storyboard storyboard, System.Windows.Media.Animation.HandoffBehavior handoffBehavior, bool isControllable);
member this.BeginStoryboard : System.Windows.Media.Animation.Storyboard * System.Windows.Media.Animation.HandoffBehavior * bool -> unit

參數

storyboard
Storyboard Storyboard Storyboard

要開始的腳本。The storyboard to begin.

handoffBehavior
HandoffBehavior HandoffBehavior HandoffBehavior

列舉型別的值,其描述若腳本中描述的屬性已顯示動畫時,所要使用的行為。A value of the enumeration that describes behavior to use if a property described in the storyboard is already animated.

isControllable
Boolean Boolean Boolean

宣告在動畫啟動後,是否可以控制 (暫停) 該動畫。Declares whether the animation is controllable (can be paused) after it is started.

備註

最常見的動畫案例不會使用這個方法。Most typical animation scenarios do not use this method. 通常您會建立Storyboard或是BeginStoryboard項目在標記中,然後將這些稱為EventTrigger內容項目上。Typically, you create the Storyboard or BeginStoryboard element in markup, and then you place these as the EventTrigger content on an element. 事件所觸發,動畫就會執行。When triggered by the event, the animation then runs. 大部分的控制層面的Storyboard可以解決會在標記中公開的屬性。Most of the control aspects of a Storyboard can be addressed by properties that are exposed in markup.

請勿使用簽章isControllable,參數,或指定該參數時false,當動畫到達"Fill"期間,會移除相關聯的動畫的時刻表時鐘。For the signatures that do not use the isControllable, parameter, or when that parameter is specified false, the timeline clocks that are associated with the animation are removed as soon as the animation reaches the "Fill" period. 因此動畫無法重新啟動之後執行一次。Therefore the animation cannot be restarted after running once. 控制動畫也必須具備的分鏡腳本X:name 指示詞或可供程式碼中參考。Controlling an animation also requires that the storyboard have an x:Name Directive or be accessible by reference in code.

遞移式行為可將指定的屬性為BeginStoryboardHandoff behavior can be specified as an attribute of BeginStoryboard.

使用 Compose HandoffBehaviorUsing the Compose HandoffBehavior

當您套用StoryboardAnimationTimeline,或AnimationClock屬性,以使用Compose HandoffBehavior、 任何Clock先前該屬性相關聯的物件會繼續耗用系統資源,計時系統會執行不會自動移除時鐘。When you apply a Storyboard, AnimationTimeline, or AnimationClock to a property by using the Compose HandoffBehavior, any Clock objects previously associated with that property continue to consume system resources; the timing system does not remove the clocks automatically.

若要避免發生效能問題,當您藉由套用大量時鐘Compose,完成之後,您應該從動畫屬性移除組成的時鐘。To avoid performance issues when you apply a large number of clocks by using Compose, you should remove composing clocks from the animated property after they complete. 有數種方式可移除時鐘:There are several ways to remove a clock:

這主要是在存留期較長的物件才會發生的動畫問題。This is primarily an issue for animations on objects that have a long lifetime. 回收物件時,其時鐘也會中斷連接,並進行記憶體回收。When an object is garbage collected, its clocks are also disconnected and garbage collected.

如需時鐘物件的詳細資訊,請參閱動畫和計時系統概觀For more information about clock objects, see Animation and Timing System Overview.

適用於