首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >针对Windows8 Metro控件的可能VisualStates文档记录在哪里?

针对Windows8 Metro控件的可能VisualStates文档记录在哪里?
EN

Stack Overflow用户
提问于 2012-05-03 12:25:40
回答 1查看 3.7K关注 0票数 7

在为win8Metro控件编写自定义ControlTemplate (XAML)时,我们需要使用VisualStateManager来根据VisualState转换更新控件。我在MSDN上看到了下面的示例,但是我找不到VisualStateGroup "CommonStates“的文档位置,除了"PointerOver”和“VisualStates”之外还定义了哪些VisualStates?你必须在SDK中寻找一个按钮的默认ControlTemplate吗?如果是,在哪里?

代码语言:javascript
复制
<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>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-05-04 05:25:16

您可以转到xaml文件的设计视图,并选择Button控件-右键单击/Edit Template/Edit Current -将显示提取的默认模板。通常情况下,控件应该使用属性注释,这些属性指示应该在模板中使用哪些可视状态,如下所示,但是当我只是导航到像Button这样的控件的定义时,我看不到它们。

代码语言:javascript
复制
[TemplateVisualState(GroupName="CommonStates", Name="Normal")]
[TemplateVisualState(GroupName="CommonStates", Name="PointerOver")]
票数 7
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10425124

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档