2012-05-03 11 views
7

Win 8 Metroコントロールのカスタムコントロールテンプレート(XAML)を書き込むときは、VisualStateManagerを使用してVisualStateの遷移に従ってコントロールを更新する必要があります。私は以下のサンプルをMSDNで見るのですが、 "PointerOver"と "Normal"以外のVisualStateGroup "CommonStates"がどこに文書化されていて、他の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")] 
関連する問題