WPF:动画自定义依赖属性? [英] WPF: animate a custom dependency property?

查看:369
本文介绍了WPF:动画自定义依赖属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

让我们说,我定义这样的依赖性:

Let's say that I've defined a dependency like this:

     public class MySampleClass
    {public static DependencyProperty MyDoubleProperty = DependencyProperty.Register("MyDouble", typeof(double), typeof(MySampleClass));
    public double MyDouble
    {
        get
        {
            return (double)GetValue(MyDoubleProperty);
        }
        set
        {
            SetValue(MyDoubleProperty, value);
        }
    }
}

我想一个DoubleAnimation是适用于该值。我怎样才能做到这一点?始终之前,我已经通过调用UIElement的BeginAnimation方法使用DoubleAnimations。

I'd like to apply a DoubleAnimation to this value. How can I do this? Always before, I've used DoubleAnimations by calling the BeginAnimation method of a UIElement.

感谢您的帮助!

推荐答案

您尝试使用DoubleAnimation是在不自UIElement继承一个类?如果不是这样,你至少应该自Animatable继承,或其他一些基类,它也支持BeginAnimation。

Are you trying to use a DoubleAnimation on a class that doesn't inherit from UIElement? If not, you should at least inherit from Animatable, or some other base class which also supports BeginAnimation.

这篇关于WPF:动画自定义依赖属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆