How do I NOT animate a list view in XAML?
Asked Answered
P

2

6

This applies to UWP, how can I disable animation of list view items? I have a method that runs every few seconds, and the fly-in animation effect makes it visually displeasing. I want to disable the effect. Not much code to share, but here's my ListView:

<ListView RelativePanel.Below="pageHeader" ItemsSource="{Binding DataItems}" />
Polygraph answered 19/4, 2017 at 1:19 Comment(1)
nothing to do with T10Noggin
S
8

You have to disable the transitions:

<ListView Transitions="{x:Null}"
          ItemContainerTransitions="{x:Null}">
</ListView>
Saimon answered 19/4, 2017 at 1:22 Comment(7)
Thank you! Is there any way to prevent the list from jumping back to the top when it refreshes? In other words, can I preserve my scroll position?Polygraph
Not sure how. Maybe create a new question and others can help.Saimon
The Transitions property doesn't seem to be available in code...?Bonnette
@jbyrd, could you post a question with your code? Because it's definitely available in code for me.Saimon
@Saimon - in a page, if I just create a ListView like var lv = new ListView(); and then start typing lv.Transi..., nothing comes up in Intellisense - see snag.gy/lE8haS.jpgBonnette
@jbyrd, if you type out lv.Transitions = null;, does your project compile? If so, then you have an issue with your Visual Studio setup. If it doesn't compile, make sure you haven't created another class in your project called ListView. If so, try using the full namespace like this var lv = new Windows.UI.Xaml.Controls.ListView();Saimon
@Saimon - oh I just realized the disconnect - I was talking about the Xamarin.Forms ListView. But you're talking about the UWP ListView - so I would need to set it in the UWP custom renderer. Got it.Bonnette
V
2

If you want to set the scroll position, try this:

this.ListView.ScrollIntoView(ListView.SelectedItem);
Vigil answered 19/4, 2017 at 3:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.