WPF 中 AnimationTimeline

本文介绍了如何在WPF中创建自定义的AnimationTimeline,以实现GridLength类型的动画效果。通过示例代码展示了一个内部类GridLengthAnimation的实现,包括From和To属性,以及GetCurrentValue方法用于计算当前动画值。
摘要由CSDN通过智能技术生成

在我看来,AnimationTimeline是用来设定一个类的值范围

比如DoubleAnimation 可以设置double的范围,实现动画,但是如果wpf本身没有定义的Animation就要我们自己写了

比如 GridLength 秒速grid放个的大小,但是没有GridLengthAnimation

前天在实现那个led显示屏软件的时候就用到了这个东西。

在网上查了一些资料,有代码有真相,下面是代码:

 

internal class GridLengthAnimation : AnimationTimeline
        {
            static GridLengthAnimation()
            {
                FromProperty = DependencyProperty.Register("From", typeof(GridLength),
                    typeof(GridLengthAnimation));

                ToProperty = DependencyProperty.Register("To", typeof(GridLength),
                    typeof(GridLengthAnimation));
            }

            public override Type TargetPropertyType
            {
                get
                {
                    return typeof(GridLength);
    

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值