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該參數時, 就會在動畫到達「填滿」期間後, 立即移除與動畫相關聯的時間軸時鐘。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該參數時, 就會在動畫到達「填滿」期間後, 立即移除與動畫相關聯的時間軸時鐘。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屬性。Handoff behavior can be specified as an attribute of BeginStoryboard.

使用撰寫 HandoffBehaviorUsing the Compose HandoffBehavior

當您Storyboard使用AnimationTimeline AnimationClock 將、Clock或套用至屬性時,先前與該屬性相關聯的任何物件都會繼續取用系統資源;計時系統會HandoffBehavior Compose不會自動移除時鐘。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該參數時, 就會在動畫到達「填滿」期間後, 立即移除與動畫相關聯的時間軸時鐘。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屬性。Handoff behavior can be specified as an attribute of BeginStoryboard.

使用撰寫 HandoffBehaviorUsing the Compose HandoffBehavior

當您Storyboard使用AnimationTimeline AnimationClock 將、Clock或套用至屬性時,先前與該屬性相關聯的任何物件都會繼續取用系統資源;計時系統會HandoffBehavior Compose不會自動移除時鐘。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.

適用於