微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

xaml – Windows 8 Metro控件的可能VisualStates在哪里记录?

在为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>
您可以转到xaml文件的设计视图,并选择Button控件 – 右键单击​​/编辑模板/编辑当前 – 将获取提取认模板.通常,控件应该使用属性来注释,这些属性指示应该在模板中使用哪些视觉状态,如下所示,但是当我导航到像Button这样的控件的定义时,我看不到它们.
[TemplateVisualState(GroupName="CommonStates",Name="normal")]
[TemplateVisualState(GroupName="CommonStates",Name="PointerOver")]

原文地址:https://www.jb51.cc/windows/364565.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐