2012-05-03 3 views
7

Win 8 Metro 컨트롤에 대한 사용자 지정 ControlTemplate (XAML)을 작성할 때 VisualStateManager를 사용하여 VisualState 전환에 따라 컨트롤을 업데이트해야합니다. 아래의 샘플을 MSDN에서 볼 수 있지만 "CommonStates"VisualStateGroup이 문서화되어 있고 "PointerOver"및 "Normal"이외의 다른 VisualStates가 정의 된 위치를 찾을 수 없습니까? 버튼에 대한 기본 ControlTemplate을 찾으려면 SDK를 파헤쳐 야합니까? 그렇다면 어디에서?가능한 VisualStates for Windows 8 Metro 컨트롤은 어디에 문서화되어 있습니까?

<ControlTemplate TargetType="Button"> 
    <Grid > 
    <VisualStateManager.VisualStateGroups> 
     <VisualStateGroup x:Name="CommonStates"> 

     <VisualStateGroup.Transitions> 

      <!--Take one half second to transition to the PointerOver state.--> 
      <VisualTransition To="PointerOver" 
           GeneratedDuration="0:0:0.5"/> 
     </VisualStateGroup.Transitions> 

     <VisualState x:Name="Normal" /> 

     <!--Change the SolidColorBrush, ButtonBrush, to red when the 
      Pointer is over the button.--> 
     <VisualState x:Name="PointerOver"> 
      <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> 
+0

참조 : http://stackoverflow.com/questions/10861160/control-styles-and-templates-for-windows-8-metro-ui –

답변

7

당신은 당신의 XAML 파일의 디자인보기와 선택 버튼 컨트롤과 함께 갈 수 있습니다 - 좌/템플릿 편집/편집 현재를 클릭은 - 당신에게 추출 된 기본 템플릿을 얻을 것이다. 일반적으로 컨트롤에는 아래의 템플릿에서 사용해야하는 시각적 상태를 나타내는 특성이 주석으로 표시되어야하지만 Button과 같은 컨트롤의 정의로 이동할 때는 볼 수 없습니다.

[TemplateVisualState(GroupName="CommonStates", Name="Normal")] 
[TemplateVisualState(GroupName="CommonStates", Name="PointerOver")] 
관련 문제