问题
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