RemoveStoryboard 類別

定義

移除 Storyboard 的觸發程序動作。

public ref class RemoveStoryboard sealed : System::Windows::Media::Animation::ControllableStoryboardAction
public sealed class RemoveStoryboard : System.Windows.Media.Animation.ControllableStoryboardAction
type RemoveStoryboard = class
    inherit ControllableStoryboardAction
Public NotInheritable Class RemoveStoryboard
Inherits ControllableStoryboardAction
繼承

範例

下列範例示範如何移除 Storyboard ,以在使用者離開包含 Storyboard 的頁面時,將其停止繼續。

<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
  Name="RootPage">
  <StackPanel>

    <!-- The MediaElement control plays the sound. -->
    <MediaElement Name="myMediaElement" />

    <Button Name="BeginButton">Begin</Button>

    <StackPanel.Triggers>

      <!-- This trigger causes the Storyboard to start (the music start) when you click the
           "BeginButton" button. -->
      <EventTrigger RoutedEvent="Button.Click" SourceName="BeginButton">
        <EventTrigger.Actions>
          <BeginStoryboard Name="myBeginStoryboard">
            <Storyboard>
              <MediaTimeline Source="C:\WINDOWS\Media\town.mid" Storyboard.TargetName="myMediaElement"  
               RepeatBehavior="Forever" />
            </Storyboard>
          </BeginStoryboard>
        </EventTrigger.Actions>
      </EventTrigger>

      <!-- When this page unloads, like when you navigate away from the page, this
           trigger causes the Storyboard to be removed and the clock to stop. If 
           you come back to this page and click the button to start the Storyboard,
           the music starts from the beginning. Alternatively, if you don't unload 
           the Storyboard when you leave the page, the Storyboard does not stop while 
           you're gone and when you navigate back to the page you hear the music  
           continuing as though you had never left. -->
      <EventTrigger RoutedEvent="Page.Unloaded" >
        <EventTrigger.Actions>
          <RemoveStoryboard BeginStoryboardName="myBeginStoryboard" />
        </EventTrigger.Actions>
      </EventTrigger>
    </StackPanel.Triggers>
  </StackPanel>
</Page>

備註

搭配 RemoveStoryboardEventTriggerTrigger 使用 來移除 Storyboard

以互動方式暫停、繼續、停止、移除或控制分鏡腳本

若要能夠暫停、繼續、移除或以互動方式控制 Storyboard ,請設定 NameBeginStoryboard 的 屬性,並使用 ControllableStoryboardAction 物件 (例如 PauseStoryboardResumeStoryboardStopStoryboard) ,藉由參考其 來控制它 NameName如果未指定 的 BeginStoryboardStoryboard 則無法在開始之後以互動方式控制 。 如需詳細資訊,請參閱 如何:使用事件觸發程式來控制腳本開始之後

移除分鏡腳本的時機

您應該使用 RemoveStoryboard 動作來移除以 的 Compose 開頭 HandoffBehavior 的任何分鏡腳本。 當動畫物件不再使用時,移除背景動畫也是個不錯的主意。 例如,如果您使用元素的事件來套用無限重複的 Loaded 分鏡腳本,您也應該建立 , EventTriggerRemoveStoryboard 該腳本會使用動作來移除元素 Unloaded 事件上的分鏡腳本。

建構函式

RemoveStoryboard()

初始化 RemoveStoryboard 類別的新執行個體。

屬性

BeginStoryboardName

取得或設定 BeginStoryboardName,開始您想要以互動方式控制的 Storyboard

(繼承來源 ControllableStoryboardAction)
DependencyObjectType

DependencyObjectType取得包裝這個實例之 CLR 型別的 。

(繼承來源 DependencyObject)
Dispatcher

取得與這個 Dispatcher 關聯的 DispatcherObject

(繼承來源 DispatcherObject)
IsSealed

取得值,這個值表示此執行個體目前是否已密封 (唯讀)。

(繼承來源 DependencyObject)

方法

CheckAccess()

判斷呼叫的執行是否可以存取這個 DispatcherObject

(繼承來源 DispatcherObject)
ClearValue(DependencyProperty)

清除屬性的區域數值。 要清除的屬性是由 DependencyProperty 識別項所指定。

(繼承來源 DependencyObject)
ClearValue(DependencyPropertyKey)

清除唯讀屬性的區域數值。 要清除的屬性是由 DependencyPropertyKey 所指定。

(繼承來源 DependencyObject)
CoerceValue(DependencyProperty)

強制轉型所指定相依性屬性的值。 完成方式是叫用存在於呼叫 DependencyObject 之相依性屬性的屬性中繼資料中所指定的任何 CoerceValueCallback 函式。

(繼承來源 DependencyObject)
Equals(Object)

判斷提供的 DependencyObject 和目前的 DependencyObject 是否相等。

(繼承來源 DependencyObject)
GetHashCode()

取得這個 DependencyObject 的雜湊碼。

(繼承來源 DependencyObject)
GetLocalValueEnumerator()

建立特定的列舉值,以判斷哪些相依性屬性在此 DependencyObject 上具有本機設定的值。

(繼承來源 DependencyObject)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
GetValue(DependencyProperty)

傳回 DependencyObject 的這個執行個體上之相依性屬性的目前有效值。

(繼承來源 DependencyObject)
InvalidateProperty(DependencyProperty)

重新評估指定相依性屬性的有效值。

(繼承來源 DependencyObject)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
OnPropertyChanged(DependencyPropertyChangedEventArgs)

每當這個 DependencyObject 上任何相依性屬性的有效值已更新時叫用。 已變更的特定相依性屬性會在事件資料中報告。

(繼承來源 DependencyObject)
ReadLocalValue(DependencyProperty)

傳回相依性屬性的區域值 (如果存在)。

(繼承來源 DependencyObject)
SetCurrentValue(DependencyProperty, Object)

設定相依性屬性的值,而不需要變更其值來源。

(繼承來源 DependencyObject)
SetValue(DependencyProperty, Object)

設定相依性屬性的區域值 (由相依性屬性的識別碼所指定)。

(繼承來源 DependencyObject)
SetValue(DependencyPropertyKey, Object)

設定唯讀相依性屬性的區域數值 (由相依性屬性的 DependencyPropertyKey 識別項所指定)。

(繼承來源 DependencyObject)
ShouldSerializeProperty(DependencyProperty)

傳回值,這個值表示序列化程序是否應該序列化所提供相依性屬性的值。

(繼承來源 DependencyObject)
ToString()

傳回代表目前物件的字串。

(繼承來源 Object)
VerifyAccess()

請強制執行可以存取這個 DispatcherObject 的呼叫執行緒。

(繼承來源 DispatcherObject)

適用於

另請參閱