5

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}" />
haosmark
  • 1,097
  • 2
  • 13
  • 27

2 Answers2

7

You have to disable the transitions:

<ListView Transitions="{x:Null}"
          ItemContainerTransitions="{x:Null}">
</ListView>
Laith
  • 6,071
  • 1
  • 33
  • 60
  • 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? – haosmark Apr 19 '17 at 01:38
  • Not sure how. Maybe create a new question and others can help. – Laith Apr 19 '17 at 02:16
  • The `Transitions` property doesn't seem to be available in code...? – jbyrd Nov 29 '17 at 17:48
  • @jbyrd, could you post a question with your code? Because it's definitely available in code for me. – Laith Nov 29 '17 at 20:20
  • @Laith - 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 https://snag.gy/lE8haS.jpg – jbyrd Nov 29 '17 at 21:19
  • @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();` – Laith Nov 30 '17 at 09:06
  • @Laith - 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. – jbyrd Nov 30 '17 at 14:43
2

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

this.ListView.ScrollIntoView(ListView.SelectedItem);
Ann Yu
  • 137
  • 1
  • 4