Infinite Scroll with Xamarin.Forms CollectionView

แชร์
ฝัง
  • เผยแพร่เมื่อ 4 ส.ค. 2024
  • The Xamarin Forms CollectionView makes it infinitely easier to implement err.. Infinite loading! In this video we will see how we implement infinite loading by using 1 property; RemainingItemsThreshold and 1 event; RemainingItemsThresholdReached.
    This sample targets using CollectionView from code-behind but also gives you information on how to do it with MVVM.
    💝 Join this channel to get access to perks:
    / @jfversluis
    🛑 Don't forget to subscribe to my channel for more amazing content: th-cam.com/users/GeraldVerslui...
    🐦 Follow me on Twitter: / jfversluis
    🔗 Links
    Sample code Repo: github.com/jfversluis/XFColle...
    CollectionView Docs: docs.microsoft.com/xamarin/xa...
    Infinite Loading Blog Post (MVVM): doumer.me/infinite-scroll-wit...
    Xamarin Forms Repo: github.com/xamarin/Xamarin.Forms
    ⏱ Timestamps
    0:00 Intro
    0:17 Sample App Outline
    1:15 Implement CollectionView
    1:50 Implement Code-Behind Loading Random Data Code
    5:40 Implement Infinite Scroll on CollectionView
    8:50 Run Sample App
    10:24 Outro
    🎥 Video edited with Camtasia (ref): techsmith.z6rjha.net/AJoeD
    🙋‍♂️ Also find my...
    Twitter: / jfversluis
    Blog: blog.verslu.is
    Twitch: / jfversluis
    All the rest: jfversluis.dev
    #XamarinForms #CollectionView #InfiniteScrollxamarin forms collectionview
  • วิทยาศาสตร์และเทคโนโลยี

ความคิดเห็น • 80

  • @shahanahmed9444
    @shahanahmed9444 ปีที่แล้ว +1

    You deserve some type of
    teaching award.

    • @jfversluis
      @jfversluis  ปีที่แล้ว

      Thank you so much Shahan 😄

  • @junalexre
    @junalexre 3 ปีที่แล้ว +3

    Thank You Very Much!!!!, as clear as water this explanation, i wonder how to implement using MVVM

    • @jfversluis
      @jfversluis  3 ปีที่แล้ว +2

      Great! I’ll see to it that I make the MVVM one too :)

    • @seanduignan294
      @seanduignan294 2 ปีที่แล้ว

      @@jfversluis Hi, how would you go about doing this for map tiles?

  • @publiclearner
    @publiclearner 2 ปีที่แล้ว

    Very helpful, thank you.

    • @jfversluis
      @jfversluis  2 ปีที่แล้ว

      My pleasure! Thanks for watching!

  • @wagnernull1096
    @wagnernull1096 ปีที่แล้ว +1

    Thanks from Brazil my friend

    • @jfversluis
      @jfversluis  ปีที่แล้ว

      Amazing! Thank you!

  • @Ihahachi
    @Ihahachi 3 ปีที่แล้ว

    Great video
    Thanks for your effort

    • @jfversluis
      @jfversluis  3 ปีที่แล้ว

      So nice of you! Thank you!

  • @Didier-cu6cb
    @Didier-cu6cb 3 ปีที่แล้ว +1

    Thanks . ❤️

    • @jfversluis
      @jfversluis  3 ปีที่แล้ว +1

      You’re very welcome!

  • @KittFanNr1
    @KittFanNr1 3 ปีที่แล้ว

    Is it also possible to do infinite scroll from bottom to up/both directions? Does the control gets slower on rising item count? Can we also remove not visible items again to reduce memory usage?

    • @jfversluis
      @jfversluis  3 ปีที่แล้ว

      Not sure, I don't think CollectionView has the capability to scroll in other directions (yet), but not 100% sure. It should not become slower, it can use virtualization, check out the cell reusable/recycling options on the CollectionView.

  • @motorparadise
    @motorparadise 3 ปีที่แล้ว

    You are just awesome.

    • @jfversluis
      @jfversluis  3 ปีที่แล้ว

      You’re not too bad yourself! 😏

    • @motorparadise
      @motorparadise 3 ปีที่แล้ว

      @@jfversluis glad to hear brother. I am your regular viewer.
      And can you provide a way/idea to:
      How to load data from the remote database whenever new data is inserted into the database online(in real-time).
      maybe Inotifier or data changed property. I don't to how to achieve this (How to load data from the remote database whenever new data is inserted into the database online(in real-time))

  • @bryanbeeblebrox8237
    @bryanbeeblebrox8237 ปีที่แล้ว +2

    Hi Gerald! I implemented Infinite Scrolling using MVVM. It works OK when there are more items to display than can fit on the screen. But when I filter my list down to having less records than the page size, the code goes into an infinite loop, calling the ItemSource over and over. I tried stepping through the code, but cannot figure out why it's doing that. In my xaml I have RemainingItemsThreshold="3" and it does this looping when the list size is 4 records. Maybe I need to add some checking into my ItemSource code?

    • @williand.529
      @williand.529 ปีที่แล้ว

      Hi, Bryan! Any update about this? i have the same problem

    • @bryanbeeblebrox8237
      @bryanbeeblebrox8237 ปีที่แล้ว

      @@williand.529 I was hoping Gerald would see my comment, but maybe the video is too old? I'll have to check and get back to you, but I don't think I ever resolved the issue and so I just load all of the items at once. I'll go back and take a look and see if maybe I did something wrong back then -- coding mobile apps is all new to me. 🙂

  • @cissemy
    @cissemy 3 ปีที่แล้ว +2

    Thanks Gerard
    How can I add filtering and sorting to this collectionview ?

    • @jfversluis
      @jfversluis  3 ปีที่แล้ว +1

      That might be a good idea for a video :)

  • @ganeshrit
    @ganeshrit 3 ปีที่แล้ว +2

    Thank you!! What about growing memory usage while doing infinite scroll, is there any inbuilt way to tackle that.

    • @JaraFPV
      @JaraFPV 3 ปีที่แล้ว

      I like how Facebook mobile did it.

    • @jfversluis
      @jfversluis  3 ปีที่แล้ว +2

      You probably want to look into cell reuse and the recycle strategy. I think there is are some built-in properties for that

  • @geraldopereira9536
    @geraldopereira9536 4 หลายเดือนก่อน

    parabéns pelo vídeo, gostaria de uma ajuda, o meu collectionview ao clicar abre outra tela, quando eu volto se eu tentar clicar novamente no mesmo item ele não abre.

  • @moatasemkremed5395
    @moatasemkremed5395 3 ปีที่แล้ว +1

    I don't know how to describe my feeling
    I'm sure you know، thanks alot
    🦧🥂☄🔥🦧🦍🐒🐵🍃

    • @jfversluis
      @jfversluis  3 ปีที่แล้ว +1

      Haha glad you liked it!

    • @moatasemkremed5395
      @moatasemkremed5395 3 ปีที่แล้ว +1

      @@jfversluis Of course
      I will give it a try with real data and share the joy with you 🥂
      thanks again 🍃

  • @khalilkhalaf8182
    @khalilkhalaf8182 3 ปีที่แล้ว +1

    Woo >>> very good , is this way like pagination (using Xamarin.Forms.Extended nuget) or or lazy loading or what ???

    • @jfversluis
      @jfversluis  3 ปีที่แล้ว

      If done right, this can definitely be used as lazy loading and pagination :)

  • @loubarr1957
    @loubarr1957 3 ปีที่แล้ว +2

    Hiya, awesome vid once again! I'm a huge fan :) I have ONE question.....my row heights are different sizes, so when loading more rows, the Y scroll sometimes makes the page 'jump' / 'jitter' upwards (only in iOS). Do you know how I can fix this? Thanks!

    • @jfversluis
      @jfversluis  3 ปีที่แล้ว +1

      Hm doesn't ring a bell, sorry about that! Have a look at the repo if there is already an issue for it and if not open one to see if it's something that can be fixed :)

    • @loubarr1957
      @loubarr1957 3 ปีที่แล้ว

      @@jfversluis okay thanks so much for the reply! Love how you reply to your fans 😊

    • @jfversluis
      @jfversluis  3 ปีที่แล้ว +1

      @@loubarr1957 Aww thank you! I try to! But it's a lot sometimes, so it might take a little longer but I try to respond to anything and everything. Thanks for noticing!

  • @oscarmoncayo9638
    @oscarmoncayo9638 3 ปีที่แล้ว +1

    Great Work my man. This works on IOS?

    • @jfversluis
      @jfversluis  3 ปีที่แล้ว

      Yes absolutely! This is pure Xamarin.Forms code so each platform that supports CollectionView this works on :)

  • @davinceecode5666
    @davinceecode5666 3 ปีที่แล้ว

    I just want to ask is this possible to replicate this but the infinite scroll will be upward? (not scrolling to bottom but scrolling to top) like the way Facebook Messenger does it.

    • @jfversluis
      @jfversluis  3 ปีที่แล้ว +1

      I don't think that is supported out of the box right now, there are some hacks with flipping the whole control upside down, but that will probably be a performance hit

    • @davinceecode5666
      @davinceecode5666 3 ปีที่แล้ว +1

      @@jfversluis I see. I hope they would have support for it soon. Thank you so much! More power!

  • @giovanninovati6024
    @giovanninovati6024 2 ปีที่แล้ว

    Hi Gerald, thanks for that tutorial. I have one problem... When it loads more data the collectionview goes back to the first element... What can i do?

    • @jfversluis
      @jfversluis  2 ปีที่แล้ว

      Do you reload all the data? I don't think it should do that

    • @giovanninovati6024
      @giovanninovati6024 2 ปีที่แล้ว

      @@jfversluis I have figured out what was wrong. Basically I created a ObservableCollection and every time the threshold command was called I cleared the ObservableCollection and assigned new values. Now instead of the ObservableCollection I have used the ObservableRangeCollection and I add some new values with AddRange.

  • @razorgmx4390
    @razorgmx4390 3 ปีที่แล้ว

    I have loading big data about 10k entries and data waiting to show about 2 minutes. But i don't know how to use this scrolling to optimize showing first elements?

    • @jfversluis
      @jfversluis  3 ปีที่แล้ว

      Load first only 20 items and as people scroll load the rest :) skip the amount that you already have and take the amount of new items you want to load

    • @razorgmx4390
      @razorgmx4390 3 ปีที่แล้ว

      Can u add link for some code?

    • @razorgmx4390
      @razorgmx4390 3 ปีที่แล้ว

      Can u make a video i'm so confused:D

    • @jfversluis
      @jfversluis  3 ปีที่แล้ว

      @@razorgmx4390 Basically it's this exact code but you don't load all the data from your backend all at once :)

    • @razorgmx4390
      @razorgmx4390 3 ปีที่แล้ว +1

      I fixed it tnx

  • @Aliensfcul
    @Aliensfcul 3 ปีที่แล้ว

    You could also do a Demo with a similar thing. Using a circular list. I know in this case you are not repeating the elements. But it would be nice to have a fixed size list we could infinite scroll as circular list.

    • @jfversluis
      @jfversluis  3 ปีที่แล้ว +1

      That sounds more like something a CarouselView would do?

    • @Aliensfcul
      @Aliensfcul 3 ปีที่แล้ว

      @@jfversluis I think so. Thanks. BTW, is there a way to keep flyout menu open on tablets but not on phones (Like IOS Email app)? Can you do a video about?

    • @jfversluis
      @jfversluis  3 ปีที่แล้ว

      You should be able to use the FlyoutLayoutBehavior for that docs.microsoft.com/xamarin/xamarin-forms/app-fundamentals/navigation/flyoutpage#control-the-detail-page-layout-behavior

    • @Aliensfcul
      @Aliensfcul 3 ปีที่แล้ว +1

      @@jfversluis yeah, solved it with this line: FlyoutBehavior="{OnIdiom Phone='Flyout', Default='Locked'}" Thanks

    • @jfversluis
      @jfversluis  3 ปีที่แล้ว

      @@Aliensfcul glad you figured it out!

  • @anassnassim
    @anassnassim 3 ปีที่แล้ว

    in the collection view, i add image when click to the image to move too the next one the app is crashed any idea

    • @jfversluis
      @jfversluis  3 ปีที่แล้ว +1

      I need a lot more information than this to be able to have an idea about that, sorry :(

    • @anassnassim
      @anassnassim 3 ปีที่แล้ว

      @@jfversluis thank you for your answer
      this is the code that I am using when I want to navigate to the next crash













      is that help ?

    • @jfversluis
      @jfversluis  3 ปีที่แล้ว +1

      @@anassnassim what is the error message?

    • @anassnassim
      @anassnassim 3 ปีที่แล้ว

      @@jfversluis no error just the phone crush

    • @jfversluis
      @jfversluis  3 ปีที่แล้ว +1

      @@anassnassim there probably is an error in the application output. Join my Discord server here discord.gg/2z6UKCnX
      We can discuss a bit easier

  • @malukishtiaq
    @malukishtiaq 3 ปีที่แล้ว

    How to create a circular list with two items?

    • @jfversluis
      @jfversluis  3 ปีที่แล้ว

      In that case you might want to look at CarouselView maybe. That has looping functionality built-in

    • @malukishtiaq
      @malukishtiaq 3 ปีที่แล้ว

      @@jfversluis got it. thank you

  • @motorparadise
    @motorparadise 3 ปีที่แล้ว

    How to load data from the remote database whenever new data is inserted into the database online(in real-time).
    maybe Inotifier or data changed property. I don't to how to achieve this (How to load data from the remote database whenever new data is inserted into the database online(in real-time))

    • @jfversluis
      @jfversluis  3 ปีที่แล้ว

      I think there is special frameworks to do that, but you probably want to look at SignalR which can keep the connection open and get data real-time.
      Realm was one database provider who also did things like this th-cam.com/video/T4A93-qmqyA/w-d-xo.html