WPF: animate a custom dependency property?

断了今生、忘了曾经 提交于 2019-12-13 20:41:29

问题


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);
        }
    }
}

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.

Thanks for your help!


回答1:


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.



来源:https://stackoverflow.com/questions/1020335/wpf-animate-a-custom-dependency-property

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!