0

I tried to make storyboard animation but I couldn't change ScrollViewer's VerticalOffset property. This code works very well with Opacity ect. properties but not with VerticalOffset and 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();
}
Justin XL
  • 38,763
  • 7
  • 88
  • 133
Weissu
  • 409
  • 3
  • 15

1 Answers1

0

Your animation won't work because VerticalOffset is read-only. You can use the ChangeView method instead.

MyScrollViewer.ChangeView(null, 0, null, false);

Have a look at my other answer here.

Justin XL
  • 38,763
  • 7
  • 88
  • 133
  • Oh...Silly me. Any way to edit ScrollViewer template to adjust scroll speed. At the moment speed is just too fast for my purpose. Looks like that I need to find other solution for my problem. – Weissu Aug 26 '17 at 03:01