VisualStateManager.VisualStateGroups 연결된 속성

정의

VisualStateGroup 개체의 컬렉션을 가져오거나 설정합니다.

see GetVisualStateGroups
see GetVisualStateGroups
see GetVisualStateGroups

예제

다음 예제에서는 간단한 ControlTemplate 에 대 한는 Button 하나를 포함 하는 Grid합니다. 도 포함 되어 있습니다를 VisualStateGroup 라는 CommonStates를 정의 하는 합니다 MouseOverNormal 상태입니다. VisualStateGroup 역시를 VisualTransition 에 대 한 0.5 초가 걸린다는 점을 지정 하는 합니다 Grid 위로 마우스 포인터를 이동할 때 녹색에서 빨간색으로 변경 하려면를 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>

설명

VisualStateGroup 의 컬렉션을 포함 VisualState 개체입니다. A VisualState 의 컬렉션을 포함 Storyboard 컨트롤이 특정 상태에 있을 때 컨트롤의 모양을 변경 하는 방법을 지정 하는 개체입니다. 예를 들어, 한 Button 를 누를 때 보다 누를 때 이와 약간 다르게 표시 해야 할 수 있습니다. 두 개의 상태를 Button 정의 누를 때 해당 하 ("Pressed")이 아닐 때 및 ("Normal").

추가한 VisualState 설정 하 여 컨트롤에는 VisualStateGroups 컨트롤에 연결 합니다. 동일한 서로 함께 사용할 수 없는 상태를 추가할 VisualStateGroup합니다. 예를 들어 합니다 CheckBox 에 두 개의 VisualStateGroup 개체입니다. 상태를 포함 하나 Normal, MouseOverPressed, 및 Disabled합니다. 다른 상태를 포함 Checked하십시오 UnChecked, 및 Indeterminate합니다. CheckBox 상태일에서 수 있습니다 MouseOverUnChecked 이와 동시에 있을 수 없습니다 있지만 MouseOverPressed 동시 상태입니다.

추가할 수는 있지만 VisualState 다른 사용자의 시각적 동작을 재정의할 수 있도록 하는 특히 유용한 방법은 요소에 개체를 Control합니다. 사용 하는 사용자 지정 컨트롤을 만드는 경우는 ControlTemplate를 추가 하 여 컨트롤에 적용할 수는 상태를 지정할 수 있습니다는 TemplateVisualStateAttribute 해당 클래스 정의에서. 그런 다음 모든 사용자가 새 ControlTemplate 컨트롤을 추가할 수에 대 한 VisualState 템플릿에 개체입니다. 같은 상태 System.Windows.TemplateVisualStateAttribute.GroupName 동일한 속해 VisualStateGroup합니다.

사용 하는 방법에 대 한 자세한 VisualStateGroup 개체를 ControlTemplate를 참조 하십시오 ControlTemplate을 만들어 기존 컨트롤의 모양 사용자 지정합니다. 만드는 방법에 대 한 자세한 내용은 사용 하는 컨트롤에 대해를 VisualStateManager를 참조 하세요 모양을 사용자 지정할 수는 제어 된 만들기합니다.

적용 대상