通过


VisualTransition.From 属性

定义

获取或设置要从中转换的名称 VisualState

public:
 property System::String ^ From { System::String ^ get(); void set(System::String ^ value); };
public string From { get; set; }
member this.From : string with get, set
Public Property From As String

属性值

要从中转换的名称 VisualState

示例

以下示例创建两个 VisualTransition 对象。 当控件从Pressed状态转换到MouseOver状态时,VisualTransition将使用具有和To设置的控件From。 当控件从非 Pressed 状态转换到 MouseOver 状态时,将使用其他状态。

<!--Take one half second to trasition to the MouseOver state.-->
<VisualTransition To="MouseOver" 
                  GeneratedDuration="0:0:0.5" />

<!--Take one hundredth of a second to transition from the
    Pressed state to the MouseOver state.-->
<VisualTransition From="Pressed" To="MouseOver" 
                  GeneratedDuration="0:0:0.01" />

注解

From 属性为可选。 A VisualTransition 可以限制为仅应用于某些状态,也可以在控件在状态之间切换时应用。 通过设置ToFrom属性来限制应用时间VisualTransition。 下表描述了限制级别从最严格到最不严格的限制。

限制类型 From 的值 To 的值
从指定状态到另一个指定状态 a 的名称 VisualState a 的名称 VisualState
从任何状态到指定状态 未设置 a 的名称 VisualState
从指定状态到任何状态 a 的名称 VisualState 未设置
从任何状态到任何其他状态 未设置 未设置

可以在引用相同状态的多个 VisualTransition 对象 VisualStateGroup ,但它们将按上表指定的顺序使用。

可以通过创建继承自 VisualStateManager 方法并重写 GoToStateCore 方法的新类来更改此行为。

适用于