Khi viết một ControlTemplate tùy chỉnh (XAML) cho một điều khiển Win 8 Metro chúng ta cần phải sử dụng VisualStateManager để cập nhật điều khiển theo chuyển tiếp VisualState. Tôi thấy mẫu dưới đây trên tất cả MSDN, nhưng tôi không thể tìm thấy nơi VisualStateGroup "CommonStates" là tài liệu và những gì VisualStates khác được định nghĩa khác hơn là "PointerOver" và "bình thường"? Bạn có phải đi đào trong SDK để tìm ControlTemplate mặc định cho một nút? Nếu vậy, ở đâu?Các VisualState có thể có cho các điều khiển Windows 8 Metro được ghi lại ở đâu?
<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>
Xem thêm: http://stackoverflow.com/questions/10861160/control-styles-and-templates-for-windows-8-metro-ui –