Bug 60608 - ListView BindingContext bound to the wrong Template
Summary: ListView BindingContext bound to the wrong Template
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 2.5.0
Hardware: Macintosh Mac OS
: Normal major
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2017-11-10 02:26 UTC by Rein Vdst
Modified: 2017-11-10 04:26 UTC (History)
3 users (show)

Tags: listview, crash, bindingcontext, ac
Is this bug a regression?: ---
Last known good build:

Repro Project (58.96 KB, application/zip)
2017-11-10 02:26 UTC, Rein Vdst

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and 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 Links.

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 for Bug 60608 on Developer Community or GitHub if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: Developer Community HTML or GitHub Markdown
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:

Description Rein Vdst 2017-11-10 02:26:19 UTC
Created attachment 25627 [details]
Repro Project

When using a DataTemplate Selector in Xamarin Forms (Android) the ViewCell BindingContext is sometimes set to the wrong Template.

If you look at  the Repro project I've added. Build it and click on an item to get the error.


ListView with a DataTemplate selector that has multiple templates (viewcells). Each of those cells use a grid to 'layout' the cell.

Those cells are getting a variable length of text (so that we force HasUnEvenRows to work).

In the repro project there are 4 templates, 1 that displays the name and 1 tag. The other 3 display the name and the first 3 tags.

Once you click on an item, a template that should display 3 tags gets it's BindingContext updated with an item that should receive the template that displays only 1 tag (as it has only 1 tag). Hence the error and you can see that the DataTemplateSelector or the mechanism behind it is Updating the bindingcontext of the wrong template.