Xaml Windows 8 Metro控件可能的可视状态记录在哪里?
为Win 8 Metro控件编写自定义控件模板(XAML)时,我们需要使用VisualStateManager根据VisualState转换更新控件。我在MSDN上看到了下面的示例,但我找不到VisualStateGroup“CommonStates”的文档位置,也找不到除了“PointerOver”和“Normal”之外定义了哪些其他VisualState?您是否必须深入SDK才能找到按钮的默认ControlTemplate?如果是,在哪里Xaml Windows 8 Metro控件可能的可视状态记录在哪里?,xaml,windows-8,windows-runtime,winrt-xaml,Xaml,Windows 8,Windows Runtime,Winrt Xaml,为Win 8 Metro控件编写自定义控件模板(XAML)时,我们需要使用VisualStateManager根据VisualState转换更新控件。我在MSDN上看到了下面的示例,但我找不到VisualStateGroup“CommonStates”的文档位置,也找不到除了“PointerOver”和“Normal”之外定义了哪些其他VisualState?您是否必须深入SDK才能找到按钮的默认ControlTemplate?如果是,在哪里 <ControlTemplate Target
<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>
您可以转到xaml文件的设计视图,选择按钮控件-右键单击/编辑模板/编辑当前-将提取默认模板。通常,控件应该用属性进行注释,这些属性指示应该在模板中使用哪些视觉状态,如下图所示,但当我只是导航到控件类按钮的定义时,我看不到它们
[TemplateVisualState(GroupName="CommonStates", Name="Normal")]
[TemplateVisualState(GroupName="CommonStates", Name="PointerOver")]
另见: