VisualStateGroup.States 属性

定义

获取互斥 VisualState 对象的集合。

public:
 property System::Collections::IList ^ States { System::Collections::IList ^ get(); };
public System.Collections.IList States { get; }
member this.States : System.Collections.IList
Public ReadOnly Property States As IList

属性值

IList

互斥 VisualState 对象的集合。

示例

以下示例为包含一GridButton实例的简单ControlTemplate方法创建一个。 它还包含一个 VisualStateGroup 命名, CommonStates用于定义 MouseOverNormal 状态。 VisualStateGroup此外,还有一个VisualTransition指定当用户将鼠标指针移到鼠标指针上方Button时,将鼠标指针从绿色更改为红色需要半秒Grid的时间。

<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>

适用于