【发布时间】:2015-04-28 17:25:32
【问题描述】:
我有一个控件,我想为只读DependencyProperty 的值设置动画
像这样使用原版动画不起作用(如预期的那样):
var animation = new DoubleAnimation(value, TimeSpan.FromMilliseconds(100));
this.BeginAnimation(SomeValueProperty, animation);
我想我正在寻找类似的东西:
var animation = new DoubleAnimation(value, TimeSpan.FromMilliseconds(100));
this.BeginAnimation(SomeValuePropertyKey, animation);
有没有一种简洁的方法可以使用框架为我的属性设置动画?
【问题讨论】:
-
即使您将
SomeValueProperty.DependencyProperty传递给 BeginAnimation,它也会给您一个运行时异常,因为 DependencyProperty.RegisterReadOnly 会在属性元数据上设置IsAnimationProhibited = true。 -
是的,如果可以从外部更改只读 dp 的 dp 是没有意义的。采用 DependencyPropertyKey 的 BeginAnimation 的重载会很好。我的想法用完了,所以我问了这个问题。不想滚动我自己的动画。
标签: wpf animation wpf-controls dependency-properties