2017-08-25 51 views
0

我试图做故事板动画,但我无法更改ScrollViewer的VerticalOffset属性。此代码与Opacity等效果很好。属性,但不与VerticalOffset和Horizo​​ntalOffset一起使用。如何设置Storyboard Animation(Windows通用应用程序)的ScrollViewer VerticalOffset属性?

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

您的动画将无法工作,因为VerticalOffset只读。您可以改用ChangeView方法。

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

看看我的其他答案here

+0

哦...傻了。任何方式来编辑ScrollViewer模板来调整滚动速度。目前速度对于我的目的来说太快了。看起来像我需要为我的问题找到其他解决方案。 – Weissu

相关问题