Språk

VisualStateGroup.States Egenskap

Definition

Hämtar samlingen av ömsesidigt uteslutande VisualState objekt.

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

Egenskapsvärde

Insamling av ömsesidigt uteslutande VisualState objekt.

Exempel

I följande exempel skapas en enkel ControlTemplate för en Button som innehåller en Grid. Den innehåller också ett VisualStateGroup med namnet CommonStates, som definierar tillstånden MouseOver och Normal . Har VisualStateGroup också en VisualTransition som anger att det tar en halv sekund för Grid att ändra från grönt till rött när användaren flyttar muspekaren över 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>

Gäller för