在为Win 8 Metro控件编写自定义ControlTemplate(XAML)时,我们需要使用VisualStateManager根据VisualState转换更新控件.我在MSDN上看到下面的示例,但是我找不到VisualStateGroup“CommonStates”的文档,除了“PointerOver”和“Normal”之外还定义了哪些其他VisualStates?您是否需要深入了解SDK以找到按钮的默认ControlTemplate?如果是这样,在哪里?
<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>