Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report on
Developer Community or GitHub with
your current version information, steps to reproduce, and relevant error
messages or log files if you are hitting an issue that looks similar to
this resolved bug and you do not yet see a matching new report.
I've created an app with a TabbedPage with three pages (all ContentPage instances). The first page uses AbsoluteLayout and contains a ContentViewController (with three items) which covers the whole screen and on top a small BoxView. The other two pages just contain a single Label.
When I select the second tab and then go back to the first tab everything works ok.
However when I select the third tab and then go back to the first tab, the carousel view is no longer showing (the BoxView element is still shown).
As extra test I turned on the indicators (ShowIndicators="True") to see if these would show up. Again there was no problem switching between first and second tabs. When I selected the third tab and then went back to the first tab, I got an null pointer exception.
To dig deeper into this I've downloaded the CarouselView source from Github and recreated the pages within the demo project.
When returning to the first tab from the third tab, the CarouselViewRenderer.OnElementChanged (CarouselView.FormsPlugin.Android project) is called and recreates the viewPager; however because the properties have not changed (I assume), viewPager.Adapter is never assigned a value within CarouselViewRenderer.OnElementPropertyChanged method. This is also what generates the Null pointer exception because the CirclePageIndicator tries to access the Adapter.Count property.
I've changed CarouselViewRenderer.OnElementPropertyChanged and added the following code to create the adapter also when the Renderer property changes:
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
viewPager.Adapter = new PageAdapter(Element, viewPager);
I've no idea if the above is the best solution to solve this problem.
Could you possibly upload a minimized reproduction to take a look at?
Created attachment 19859 [details]
Source of simple app that uses TabbedPage with CarouselView
To use source (Visual Studio):
1. Create new project
2. Cross platform -> Blank App (Xamarin Forms Portable)
3. Right click solution -> Manage NU Packages
4. Add CarouselView
5. Unzip source into Forms project folder
The full solution (17mb) can be downloaded from: http://www.ultraforce.com/carousel_test.zip
To see bug:
1. Run app on Android (should show 3 tabs with zoo image and blue box)
2. Select 2nd tab
3. Select 1st tab (zoo image should become visible again)
4. Select 3rd tab
5. Select 1st tab (only the blue box is shown)
App has been tested on Samsung S7
Setting ShowIndicators to True (in TabPage1.xaml) will crash the app when returning to the 1st tab.
The Zoo data (without the monkeys) comes from:
CarouselView will be deprecated and replaced with https://github.com/xamarin/Xamarin.Forms/pull/853.