• UWP 动画


    一:StoryBoard

    一般翻译成演示图版或者故事板,就像电影中的情节串联板,它是一个动画时间线的容器。

    二:动画的分类

          简单动画:以Animation结尾,例如DoubleAnimation

       关键帧动画:以AnimationUsingKeyFrames结尾

      简单动画主要是定义两个值,一个起点,一个终点,在两个值之间生成动画,可以用来满足简单的动画需求。

      关键帧动画更好理解,你可以像flash里一样,通过不同的关键帧来定义动画。这样做的动画会比简单动画来的细致一些。

    三:VisualState

    在上一篇中,通过编辑模板vs会自动生成一个对应控件的Style。我们可以在VisualStateManager里改一下不同状态下的控件样式。

    <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="Button">
                            <Grid x:Name="RootGrid">
                                <VisualStateManager.VisualStateGroups>
                                    <VisualStateGroup x:Name="CommonStates">
                                        <VisualState x:Name="Normal">
                                            <Storyboard>
                                                <DoubleAnimation Duration="0:0:0.5" From="0" To="0.1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="Mask" ></DoubleAnimation>
                                            </Storyboard>
                                        </VisualState>
                                        <VisualState x:Name="PointerOver">
                                            <Storyboard>
                                                <DoubleAnimation Duration="0:0:0.5" From="0.2" To="0" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="Mask" ></DoubleAnimation>
                                            </Storyboard>
                                        </VisualState>
                                        <VisualState x:Name="Pressed">
                                            <Storyboard>
                                                <DoubleAnimation Duration="0:0:0.5" From="0.2" To="0" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="Mask" ></DoubleAnimation>
                                            </Storyboard>
                                        </VisualState>
                                        <VisualState x:Name="Disabled">
                                            <Storyboard>
                                            </Storyboard>
                                        </VisualState>
                                    </VisualStateGroup>
                                </VisualStateManager.VisualStateGroups>
                                <Ellipse Width="{TemplateBinding Width}"
                                         Height="{TemplateBinding Height}"
                                         Fill="{TemplateBinding Background}"></Ellipse>
                                <ContentPresenter x:Name="ContentPresenter" 
                                                  AutomationProperties.AccessibilityView="Raw" 
                                                  BorderBrush="{TemplateBinding BorderBrush}" 
                                                  BorderThickness="{TemplateBinding BorderThickness}" 
                                                  ContentTemplate="{TemplateBinding ContentTemplate}" 
                                                  ContentTransitions="{TemplateBinding ContentTransitions}"
                                                  Content="{TemplateBinding Content}" 
                                                  HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" 
                                                  Padding="{TemplateBinding Padding}" 
                                                  VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"/>
                                <Ellipse Name="Mask" Fill="Black" Opacity="0.1"/>
                            </Grid>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>

    每一个VisualState代表一个状态。Normal默认状态,PointerOver鼠标移上状态,Pressed鼠标安按下状态,Disabled不可用状态

    通过简单动画DoubleAnimation来定义一些简单的动画。

      

    ---some words---

    1.StoryBoard:故事板

    -----the end-------

  • 相关阅读:
    PHP 魔术常量
    PHP 魔术方法
    php函数serialize()与unserialize()
    10 件有关 JavaScript 让人费解的事情
    windows下安装Python2和Python3共存
    SQL 行转列===列转行
    Redis 分布式锁
    RabbitMQ
    @Autowired
    AOP 日志切面
  • 原文地址:https://www.cnblogs.com/MzwCat/p/7637371.html
Copyright © 2020-2023  润新知