为Windows 8地铁控制可能VisualStates在哪里记录?(Where are the p

2019-09-16 23:34发布

当一个双赢8地铁控制编写自定义的ControlTemplate(XAML),我们需要使用VisualStateManager根据的VisualState过渡到更新控制。 我看到了下面的示例遍MSDN,但我找不到其中VisualStateGroup“CommonStates”是记录和其他什么VisualStates的定义比“PointerOver”和“正常”之外? 你必须去挖掘在SDK中找到一个按钮的默认控件模板? 如果是这样,在哪里?

<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>

Answer 1:

你可以去你的XAML文件的设计视图,并与选择的按钮控制 - 右键/编辑模板/编辑电流 - 将让你提取的默认模板。 通常控制应当与指示哪个可视状态应该像下面的模板中使用的属性来注解,但我不能看到他们的时候我只是导航到像按钮控制的定义。

[TemplateVisualState(GroupName="CommonStates", Name="Normal")]
[TemplateVisualState(GroupName="CommonStates", Name="PointerOver")]


文章来源: Where are the possible VisualStates for Windows 8 Metro controls documented?