Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

CarouselPage and ObservableCollection

$
0
0

Somehow I am unable to get it work (i.e. CarouselPage with ObservableCollection)
This is how my app works (It displays images and description about it)

1) Read database and get the file name and details (around 100 images) I read it as List
2) Populate listview with the file name and some basic info
3) Upon user action on listview show CarouselPage and allow user to scroll and view all the images with detailed description

Now I tried to use ObservableCollection with to reduce the memory consumption and performance issue
Here is what I do :
1) I set an ObservableCollection as ItemsSource for my CarouselPage
2) Initially three items are added to it ..... the clicked item(on listview), previous item and next item
3) When user navigates/scrolls left or right I catch the event in OnCurrentPageChanged
4) Inside OnCurrentPageChanged I check by comparing the SelectedItem if user has swiped/navigated to next or previous Image
5) Accordingly I remove a page and add another to the ObservableCollection and set the SelectedItem

Now the problem I face here is that after scrolling/navigating to next/previous image and changing the ObservableCollection accordingly I never land up in desired page.
Also the OnCurrentPageChanged event gets called multiple times ..... is it so because of ObservableCollection

Can anyone share some sudo/sample code/project for Lazy Loading of CarouselPage

Many Thanks in advance.


Viewing all articles
Browse latest Browse all 58056

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>