zoukankan      html  css  js  c++  java
  • WP7备注(38)(VisualStateManager)

    TemplateVisualStateAttribute:

    [TemplateVisualStateAttribute(Name = "Disabled", GroupName = "CommonStates")]
    [TemplateVisualStateAttribute(Name = "Normal", GroupName = "CommonStates")]
    [TemplateVisualStateAttribute(Name = "MouseOver", GroupName = "CommonStates")]
    [TemplateVisualStateAttribute(Name = "Pressed", GroupName = "CommonStates")]
    [TemplateVisualStateAttribute(Name = "Unfocused", GroupName = "FocusStates")]
    [TemplateVisualStateAttribute(Name = "Focused", GroupName = "FocusStates")]
    public class Button : ButtonBase

    具体使用:

    <phone:PhoneApplicationPage.Resources>
    <ControlTemplate x:Key="buttonTemplate" TargetType="Button">
    <Grid>
    <VisualStateManager.VisualStateGroups>
    <VisualStateGroup x:Name="CommonStates">
    <VisualState x:Name="Normal" />
    <VisualState x:Name="MouseOver" />
    <VisualState x:Name="Pressed">
    <Storyboard>
    <ObjectAnimationUsingKeyFrames
    Storyboard.TargetName="border"
    Storyboard.TargetProperty="Background">
    <DiscreteObjectKeyFrame KeyTime="0:0:0"
    Value="{StaticResource PhoneForegroundBrush}" />
    </ObjectAnimationUsingKeyFrames>
    <ObjectAnimationUsingKeyFrames
    Storyboard.TargetName="contentControl"
    Storyboard.TargetProperty="Foreground">
    <DiscreteObjectKeyFrame KeyTime="0:0:0"
    Value="{StaticResource PhoneBackgroundBrush}" />
    </ObjectAnimationUsingKeyFrames>
    </Storyboard>
    </VisualState>
    <VisualState x:Name="Disabled">
    <Storyboard>
    <DoubleAnimation Storyboard.TargetName="disableRect"
    Storyboard.TargetProperty="Opacity"
    To="0.6" Duration="0:0:0" />
    </Storyboard>
    </VisualState>
    </VisualStateGroup>
    </VisualStateManager.VisualStateGroups>
    <Border Name="border"
    BorderBrush="{TemplateBinding BorderBrush}"
    BorderThickness="{TemplateBinding BorderThickness}"
    Background="{TemplateBinding Background}"
    CornerRadius="12">
    <ContentControl Name="contentControl"
    Content="{TemplateBinding Content}"
    ContentTemplate="{TemplateBinding ContentTemplate}"
    Margin="{TemplateBinding Padding}"
    HorizontalAlignment="{TemplateBinding
    HorizontalContentAlignment}"
    VerticalAlignment="{TemplateBinding
    VerticalContentAlignment}" />
    </Border>
    <Rectangle Name="disableRect"
    Fill="{StaticResource PhoneBackgroundBrush}"
    Opacity="0" />
    </Grid>
    </ControlTemplate>
    <Style x:Key="buttonStyle" TargetType="Button">
    <Setter Property="BorderBrush" Value="{StaticResource PhoneAccentBrush}" />
    <Setter Property="BorderThickness" Value="6" />
    <Setter Property="Background" Value="{StaticResource PhoneChromeBrush}" />
    <Setter Property="Template" Value="{StaticResource buttonTemplate}" />
    </Style>
    </phone:PhoneApplicationPage.Resources>

    状态跳转:

    VisualStateManager.GoToElementState(UIElemnt, "Normal", true);

  • 相关阅读:
    爬虫(Xpath)——爬tieba.baidu.com
    爬虫(正则)——爬neihan8
    爬虫(cookie)——renren模拟登陆
    爬虫(ProxyHandler)——代理
    爬虫(GET)——handler处理器和自定义opener
    爬虫(AJEX)——豆瓣动态页面
    爬虫(POST)——有道翻译(有bug)
    一次跨域请求出现 OPTIONS 请求的问题及解决方法
    现代JS中的流程控制:详解Callbacks 、Promises 、Async/Await
    nodejs中的子进程,深入解析child_process模块和cluster模块
  • 原文地址:https://www.cnblogs.com/otomii/p/2041086.html
Copyright © 2011-2022 走看看