• WPF中的动画


    wpf中的的动画效果,有比较多的实现方式
    首先是dispatchertimer这个类,类似timer类,通过设置一个时间间隔来执行方法,可以动态的实现某些动画效果
    具体空间是System.Windows.Threading.DispatcherTimer。可以参考一下msdn,实现比较简单

    wpf中动画效果大部分集中在using System.Windows.Media.Animation下
    wpf的动画效果必须是在依赖属性上,这个空间下有很多类,根据不同类型的属性要用不同类型的动画来实现

    比如可以分为:Boolean,int,byte,char,double,single等类型
    比如控件width,height,fontsize等都是double,那就要用doubleanimatin类了

    使用c#代码实现动画比较简单,这个例子是改变按钮btn的width
     DoubleAnimation da = new DoubleAnimation();
                da.Duration = new Duration(TimeSpan.FromSeconds(5));//持续时间
                da.From = 80;//起始大小
                da.To = 300;//结束大小
                da.FillBehavior = FillBehavior.HoldEnd;//结束以后保持现在的状态or恢复到最初的状态

                this.btn.BeginAnimation(Button.WidthProperty, da);//按钮btn调用

    使用xaml实现动画,看起来比较复杂,标签比较多
    tackPanel>
            <Button Name="btn" Content="Hello World"  Width="80" >
                <Button.Triggers>
                    <EventTrigger RoutedEvent="Button.Click">
                        <BeginStoryboard>
                            <Storyboard TargetProperty="Width">//附加属性
                                <DoubleAnimation From="80" To="300" Duration="0:0:2" FillBehavior="Stop"></DoubleAnimation>
                            </Storyboard>
                        </BeginStoryboard>
                    </EventTrigger>
                </Button.Triggers>

    DoubleAnimation 对像几个属性
    from:起始大小
    to:结束大小
    By:结束值是Form+By。to和by不能同时指定,如果同时指定,by将被忽略
    fillbehavior:结束以后的状态:stop恢复到原来,holdend保持

    本文使用Blog_Backup未注册版本导出,请到soft.pt42.com注册。

  • 相关阅读:
    多态_python的小窝_百度空间
    可直接下载空间客户端
    简明 Python 教程 / 面向对象的编程 / 类与对象的方法
    C++ 基础 woaidongmao C++博客 good 量产
    set has enumerate
    python invoke super parent method
    分享:常用汉字的unicode 编码
    数据库调整也可以遵循“开闭原则”
    Ninject超轻量级的依赖注入工具
    点某个链接进网站,会发这个链接的会员加积分,实现方法(有时间限制)
  • 原文地址:https://www.cnblogs.com/zjypp/p/2319318.html
Copyright © 2020-2023  润新知