我似乎无法做myObject.BeginAnimation(dp , animation)
。
这是一个错误还是已被更改?
答案 0 :(得分:7)
您需要使用故事板。将动画添加到故事板并让故事板开始动画。
var storyboard = new Storyboard();
var opacityAnimation = new DoubleAnimation {
From = 0,
To = 1,
Duration = DurationHelper.FromTimeSpan(TimeSpan.FromSeconds(1)),
};
storyboard.Children.Add(opacityAnimation);
Storyboard.SetTargetProperty(opacityAnimation, "Opacity");
Storyboard.SetTarget(storyboard, myObject);
storyboard.Begin();