我在Windows 8.1列表视图中有一个项目列表我想要做的是,在按钮单击时我想自动滚动列表视图中的项目。
如果我在stackpanel中添加这些项并将其包装在scrollviewer控件中,我就能实现这一点。但是我无法为列表视图的内置滚动查看器设置动画。
因此,是否可以使用W8.1商店应用中的故事板为listview / gridview的默认滚动查看器设置动画。
<ListView x:Name="OnboardPanel" HorizontalAlignment="Stretch" ScrollViewer.VerticalScrollBarVisibility="Hidden">
<ListView>
<ItemsPanelTemplate>
<ItemsWrapGrid x:Name="OnboardWrapGrid" MaximumRowsOrColumns="6" Orientation="Horizontal" HorizontalAlignment="Stretch" Background="Red"/>
</ItemsPanelTemplate>
</ListView>
<ListView>
<DataTemplate>
<Image Source="{Binding ImageName}" Margin="1" Stretch="UniformToFill"/>
</DataTemplate>
</ListView>
</ListView>
private void Button_Click(object sender, RoutedEventArgs e)
{
//myStoryboard.Begin();
Storyboard storyboard1 = new Storyboard();
DoubleAnimation verticalScrollOffsetAnimation = new DoubleAnimation
{
From = 0,
To = 1000,
Duration = new TimeSpan(0, 0, 0, 3, 0),
EnableDependentAnimation = true
};
storyboard1.Children.Add(verticalScrollOffsetAnimation);
Storyboard.SetTarget(verticalScrollOffsetAnimation, OnboardPanel.GetScrollViewer());
Storyboard.SetTargetProperty(verticalScrollOffsetAnimation, "VerticalOffset");
//storyboard1.FillBehavior = FillBehavior.Stop;
//storyboard1.RepeatBehavior = RepeatBehavior.Forever;
storyboard1.Begin();
}
答案 0 :(得分:0)
我在下面用作示例并进行了一些代码更改,以添加故事板动画来为listview中的scrollviewer设置动画。