我在 Windows 8.1 listview 中有一个项目列表,我想要做的是,单击一个按钮,我喜欢自动滚动列表视图中的项目。
如果我在 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();
}