VisualStateGroup.Transitions 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得物品集合 VisualTransition 。
public:
property System::Collections::IList ^ Transitions { System::Collections::IList ^ get(); };
public System.Collections.IList Transitions { get; }
member this.Transitions : System.Collections.IList
Public ReadOnly Property Transitions As IList
屬性值
這些物品的集合 VisualTransition 。
範例
以下範例創造一個包含 的ControlTemplate簡單 ButtonGrid 。 它也包含一個 VisualStateGroup 名為 CommonStates的 ,定義 MouseOver 了 和 Normal 狀態。
VisualStateGroup此外,VisualTransition還有一個 表示當使用者將滑鼠指標移到Grid該 .5 時,從Button綠色變為紅色需要半秒。
<ControlTemplate TargetType="Button">
<Grid >
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualStateGroup.Transitions>
<!--Take one half second to trasition to the MouseOver state.-->
<VisualTransition To="MouseOver"
GeneratedDuration="0:0:0.5"/>
</VisualStateGroup.Transitions>
<VisualState x:Name="Normal" />
<!--Change the SolidColorBrush, ButtonBrush, to red when the
mouse is over the button.-->
<VisualState x:Name="MouseOver">
<Storyboard>
<ColorAnimation Storyboard.TargetName="ButtonBrush"
Storyboard.TargetProperty="Color" To="Red" />
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Grid.Background>
<SolidColorBrush x:Name="ButtonBrush" Color="Green"/>
</Grid.Background>
</Grid>
</ControlTemplate>
備註
VisualTransition當 中定義Transitions的狀態間控制轉移時,物件VisualStateGroup會被套用。