我尝试制作故事板动画,但我无法更改ScrollViewer的VerticalOffset属性。此代码适用于Opacity等。属性但不包含VerticalOffset和HorizontalOffset。
private void MakeVerticalAnimation()
{
Storyboard AnimationStoryboard = new Storyboard();
DoubleAnimation VerticalOffsetAnimation = new DoubleAnimation();
Storyboard.SetTarget(VerticalOffsetAnimation, MyScrollViewer);
Storyboard.SetTargetProperty(VerticalOffsetAnimation, "VerticalOffset");
VerticalOffsetAnimation.EnableDependentAnimation = true;
VerticalOffsetAnimation.From = 100;
VerticalOffsetAnimation.To = 0;
VerticalOffsetAnimation.Duration = TimeSpan.FromSeconds(3);
AnimationStoryboard.Children.Add(VerticalOffsetAnimation);
AnimationStoryboard.Begin();
}
答案 0 :(得分:0)
您的动画无效,因为VerticalOffset
只读。您可以改用ChangeView
方法。
MyScrollViewer.ChangeView(null, 0, null, false);
看看我的另一个答案here。