Click here to Skip to main content
15,900,378 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a list of items inside windows 8.1 listview what I wanted to do is, on a button click I like to auto scroll the items inside list view.

XML
<ListView x:Name="OnboardPanel" HorizontalAlignment="Stretch" ScrollViewer.VerticalScrollBarVisibility="Hidden">
            <ListView>
                <ItemsPanelTemplate>
                    <ItemsWrapGrid x:Name="OnboardWrapGrid" MaximumRowsOrColumns="6" Orientation="Horizontal" HorizontalAlignment="Stretch" removed="Red"/>
                </ItemsPanelTemplate>
            </ListView>
            <ListView>
                <DataTemplate>
                    <Image Source="{Binding ImageName}" Margin="1" Stretch="UniformToFill"/>
                </DataTemplate>
            </ListView>
        </ListView>


my code behind is as follows

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


What I have tried:

I was able to achieve this if I add those items inside stackpanel and wrapped it within scrollviewer control. But I was unable to animate the inbuilt scrollviewer of the listview.

So Is it possible to animate listview / gridview's default scrollviewer using storyboard in W8.1 store app.
Posted
Updated 28-Feb-16 22:45pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900