【问题标题】:How to set ScrollViewer VerticalOffset property for Storyboard Animation (Windows Universal App)?如何为 Storyboard Animation(Windows 通用应用程序)设置 ScrollViewer VerticalOffset 属性?
【发布时间】:2018-02-03 18:16:24
【问题描述】:

我尝试制作情节提要动画,但无法更改 ScrollViewer 的 VerticalOffset 属性。此代码与 Opacity 等配合得很好。属性,但不使用 VerticalOffset 和 Horizo​​ntalOffset。

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();
}

【问题讨论】:

    标签: c# uwp storyboard windows-10-universal scrollviewer


    【解决方案1】:

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

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

    看看我的另一个答案here

    【讨论】:

    • 哦……真傻。编辑 ScrollViewer 模板以调整滚动速度的任何方式。目前速度对于我的目的来说太快了。看来我需要为我的问题找到其他解决方案。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-28
    • 1970-01-01
    • 2011-07-09
    • 2016-07-04
    • 1970-01-01
    相关资源
    最近更新 更多