Possible to disable row animation in ListView using Xamarin.Forms?

ShmooShmoo USMember ✭✭

I have a Xamarin.Forms ListView with pull-to-refresh enabled. On iOS, the default animation used when rows are inserted just doesn't look right - rows animate in a seemingly random order.

I'd like to completely disable these animations if possible, but I'm open to other solutions.

Thanks!

Answers

  • alexrainmanalexrainman USMember ✭✭

    I am looking for the same solution. Did you find the way?

  • ShmooShmoo USMember ✭✭

    @alexrainman1975,

    If you use a List instead of an ObservableCollection and just set ItemsSource when refreshing, it won't animate rows.

    I believe you would still be able to use bindings like so:

    public static readonly BindableProperty ItemsProperty = 
      BindableProperty.Create<MyViewModel, List<Item>> (p => p.Items, null);
    
    public List<Item> Items {
      get { return (List<Item>)GetValue (ItemsProperty); }
      set { SetValue (ItemsProperty, value); }
    }
    

    Then, just bind ItemsSource to your view model's Items property. I haven't tested this though, so it may not work.

  • RaymondKellyRaymondKelly USMember ✭✭✭

    Is there any update on this? I agree with @Shmoo , items seem to paint in the wrong order while they are animating. Would rather not switch from ObservableCollection.

  • Use a CustomListViewRenderer and override the OnElementChange method inside which you can do :
    AnimationEnabled = false;
    protected override void OnElementChanged(ElementChangedEventArgs<ListView> e) { base.OnElementChanged(e); AnimationsEnabled = false; }

  • ZaneCampbellZaneCampbell USMember ✭✭

    @VedaviBalaji said:
    Use a CustomListViewRenderer and override the OnElementChange method inside which you can do :
    AnimationEnabled = false;
    protected override void OnElementChanged(ElementChangedEventArgs<ListView> e) { base.OnElementChanged(e); AnimationsEnabled = false; }

    Unfortunately this seems to disable all (or most) animations app wide, not just for lists. Is there a way to disable ListView cell animations only?

  • ThePickleThePickle Member ✭✭

    I get an error on AnimationsEnabled = false;
    How did you create this custom render for listview on UWP to disable all animation?

Sign In or Register to comment.