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.
## Description (From case file):
I am having an issue using a ListView in Xamarin Forms on Android. The main page contains a single ListView that has a custom ViewCell template, an "Add" button and a label that displays a count of "items". The custom template consists of 2 buttons and 2 labels in a horizontal StackLayout. One of the buttons is hidden by default. Backing the application are 2 view models. The main view model (ViewModel1) contains an Observablecollection of view models (ViewModel2) that are used as the ItemsSource for the ListView.
I am trying to implement the following behavior:
1. The user taps the "Add" button at the bottom of the page - This adds a new ViewModel2 to the ObservableCollection and through binding is reflected in the ListView
2. The user taps the button labeled "TOGGLE" on the ListView item - This shows the second button labeled "INCREMENT" at the start of the ViewCell, all other controls in the ViewCell are pushed to the right
3. The user taps the "INCREMENT" button to increment a counter - The incremented value is shown in the ViewCell in red text and also updates a total count in the main page
4. The user taps the "TOGGLE" button again and the "INCREMENT" button is hidden and the ViewCell UI collapses left back to its original state
Everything works in Android up to step 4. When the user taps the "TOGGLE" button again the "INCREMENT" button is hidden BUT the UI does not update and collapse back to the left. The space is just left empty at that point. Adding additional items to the list at this point results in undefined behavior. I suspect this has something to do with reuse of cells in Android but because this is in Forms I cannot dig in deep enough to find the issue.
## Steps to reproduce:
1. Open attached test project and launch the Android project.
2. Add some list items.
3. Toggle some of the items.
4. Click and increment button.
5. Click Toggle again.
6. Toggle some items to see the behavior shown in the Android screen cast below. ON my end, the issue seems to mostly occur with the first few items on the list.
## Expected result
When clicking toggle, the increment button will appear and the Toggle button and the text will move to the right to make room for the increment button.
## Actual result
In some items, clicking toggle will add the increment button but the other item elements remain in place.
## screencast of issue. Note, iOS does not display this issue.
iOS Screen cast: http://screencast.com/t/1KDaIuOr8
Android Screen cast: http://screencast.com/t/GlXVgwgi
Tested using Forms version 188.8.131.5243. Erroneous behavior seems to start only after an increment button is pressed.
This should be resolved in 1.3.0