VisualStateManager.GoToStateCore 方法

定義

會讓控制項在狀態之間轉換。

protected:
 virtual bool GoToStateCore(System::Windows::FrameworkElement ^ control, System::Windows::FrameworkElement ^ stateGroupsRoot, System::String ^ stateName, System::Windows::VisualStateGroup ^ group, System::Windows::VisualState ^ state, bool useTransitions);
protected virtual bool GoToStateCore (System.Windows.FrameworkElement control, System.Windows.FrameworkElement stateGroupsRoot, string stateName, System.Windows.VisualStateGroup group, System.Windows.VisualState state, bool useTransitions);
abstract member GoToStateCore : System.Windows.FrameworkElement * System.Windows.FrameworkElement * string * System.Windows.VisualStateGroup * System.Windows.VisualState * bool -> bool
override this.GoToStateCore : System.Windows.FrameworkElement * System.Windows.FrameworkElement * string * System.Windows.VisualStateGroup * System.Windows.VisualState * bool -> bool
Protected Overridable Function GoToStateCore (control As FrameworkElement, stateGroupsRoot As FrameworkElement, stateName As String, group As VisualStateGroup, state As VisualState, useTransitions As Boolean) As Boolean

參數

control
FrameworkElement

控制項要在之間轉換的兩個狀態。

stateGroupsRoot
FrameworkElement

包含 VisualStateManager 的根項目。

stateName
String

轉換後的狀態名稱。

group
VisualStateGroup

狀態所屬的 VisualStateGroup

state
VisualState

轉換後的狀態表示。

useTransitions
Boolean

true 表示使用 VisualTransition 物件在狀態之間轉換,否則為 false

傳回

如果控制項成功轉換到新的狀態,則為 true,否則為 false

備註

方法 GoToStateCore 會執行適當啟動和停止與轉換相關聯的分鏡腳本所需的邏輯。 當控制項呼叫 GoToState 以變更其狀態時,會 VisualStateManager 執行下列動作:

  • 首先,如果 VisualState 控制項轉換至 的 , Storyboard 腳本就會開始。 然後,如果 VisualState 控制項來自 的 具有 Storyboard ,腳本就會結束。

  • 如果控制項已經處於 stateName 狀態, GoToState 則不會採取任何動作並傳 true 回 。

  • 如果 stateName 不存在於 ControlTemplatecontrol 中, GoToState 則不會採取任何動作並傳 false 回 。

您可以實作自己的 VisualStateManager ,以提供不同邏輯來轉換狀態。 例如,您可以變更先前所述的邏輯,也可以提供在自訂動畫類型之間轉換的邏輯。 若要實作 VisualStateManager ,請建立繼承自 VisualStateManager 的類別,並覆寫 GoToStateCore 方法。 若要使用自訂類別,請將 CustomVisualStateManager 屬性設定為自訂類型的 物件。

適用於