0
votes

I am working on a xamarin forms project which have a carousel page container, and content pages as its children are created dynamically on different condition checks. (Minimum 8 children in my case)

Let's take the mentioned minimum case. I enter some values in entry/picker controls in the 1st child and then navigate/swipe pages till 5th child. When I came back to the first child page, the values I entered/selected are now vanished/refreshed.

I have noticed that carousel page saves only 3 pages data in it. i.e. (Left Page, Current Page and the Right Page). And Tabbed page saves 4 pages data.

I want the values to stay in the child page where I entered whether I navigate to the last most page or in the middle and navigate back to that page.

I have googled via the letters as "Carousel page/ Tabbed page Saved states" etc. but unable to find something useful.

So, I need to know the property name/ method name etc. by which xamarin forms setting the limit of carousel page as 3 and tabbed page as 4.

Waiting for your response.

Thanks.

1
Save the content page state via the page lifecycles and restore them when needed, otherwise you will need to modify the Xamarin.Forms source code. MultiPage is where you would need to start as it is the abstract class that is used as the Page "container" for TabbedPage and CarouselPage : github.com/xamarin/Xamarin.Forms/blob/…SushiHangover
@SushiHangover Thanks. but the issue is that I have not created any custom control yet even modification. so I don't know what, where and how to modify in the page life-cycles to save and retrieve states. Can you please provide the documentation link for page life-cycles? it will be really appreciated.Fahad Ali Qureshi
@SushiHangover if it's an event of a ContentPage, then how it's possible that CarouselPage saves different number of ContentPage states than TabbedPage? with same number of ContentPages in both?Fahad Ali Qureshi
CarouselPage/TabbedPage are not saving any "state", it is a form of recycling. It creates and releases pages based upon usage. You could have a hundred catalog items bound to the carousel and as the user swipes between them, they are getting create/referenced and then de-referenced and garbage collected as you would very quickly runout of memory if all hundred pages were statically/hard referenced by the carousel. (Same idea when using a ListView in recycler mode), in fact the original CarouselPage code did just that and was un-usable in any real-world usageSushiHangover

1 Answers

0
votes

OK I found that I was using a Custom Picker Control and the value refreshing issue is with it. I just forget to set the selectedIndex of the picker on OnElementChanged event.