Bug 53987 - Strange message about wrong DataBinding of ObservableCollection to ItemsSource of ListView when item removed
Summary: Strange message about wrong DataBinding of ObservableCollection to ItemsSourc...
Alias: None
Product: Forms
Classification: Xamarin
Component: Android ()
Version: 2.3.3
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Jimmy [MSFT]
Depends on:
Reported: 2017-03-26 11:48 UTC by marek.prerovsky
Modified: 2017-03-30 16:55 UTC (History)
2 users (show)

Tags: android, databinding, viewcell
Is this bug a regression?: ---
Last known good build:

repro project for VS 2015 (299.36 KB, application/x-zip-compressed)
2017-03-26 11:48 UTC, marek.prerovsky

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 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.

Related Links:

Description marek.prerovsky 2017-03-26 11:48:47 UTC
Created attachment 20849 [details]
repro project for VS 2015

Original discussion: https://forums.xamarin.com/discussion/91311/is-this-a-bug-in-binding-to-itemssource-of-listview

I have prepared minimal project to reproduce the issue. 

The problem is when removing item from ObservableCollection<> binded to ItemsSource of ListView then the BindingContext of ViewCell is set for a while to the object being removed.

Run the project in Android emulator and when you click 'Remove' button then you can see in debug output this message about strange binding error:
[0:] Binding: 'Part' property not found on 'XamBugListView01.MainPage+ItemPart', target property: 'Xamarin.Forms.Label.BindingContext'

The project uses Xamarin.Forms 

Here is the source code of MainPage.xml.cs:

    using System;
    using System.Collections.Generic;
    using System.Collections.ObjectModel;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using Xamarin.Forms;
    namespace XamBugListView01
        public partial class MainPage : ContentPage
            private ObservableCollection<Item> _allItems = new ObservableCollection<Item>();
            public MainPage()
                _allItems.Add(new Item());
                _allItems.Add(new Item());
                _listView.BindingContext =
                        AllItems = _allItems
            private void RemoveClicked(object sender, EventArgs ea)
            public class Item
                public ItemPart Part { get; private set; }
                public Item()
                    Part = new ItemPart();
            public class ItemPart
                private static int _counter;
                public string Name { get; private set; }
                public ItemPart()
                    Name = "item part " + (++_counter);
                //public ItemPart Part
                //    get
                //    {
                //        throw new InvalidOperationException("Property Part of ItemPart is never used in any code and any XAML.");
                //    }
Here is the source code of MainPage.xml:

    <?xml version="1.0" encoding="utf-8" ?>
    <ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
      <StackLayout Orientation="Vertical">
        <ListView Grid.Row="1"
                  ItemsSource="{Binding Path=AllItems}"
                <Label BindingContext="{Binding Path=Part}" Text="{Binding Path=Name}" />
        <Button Text="Remove"
                Clicked="RemoveClicked" />
Everything else is generated from the template 'Blank Xaml App (Xamarin.Forms.Portable) C#' (project name is XamBugListView01).

Whole solution is attached in ZIP archive.
Comment 1 Jimmy [MSFT] 2017-03-27 14:41:28 UTC
Thank you for filing this report! Let me run the attached project to see if I can confirm this issue and I will update the report with my results.
Comment 2 Jimmy [MSFT] 2017-03-30 16:55:46 UTC
I was able to reproduce this with the attached project on Android and with Forms When the item was removed the debug output would show:

> [0:] Binding: 'Part' property not found on 'XamBugListView01.MainPage+ItemPart', target property: 'Xamarin.Forms.Label.BindingContext'

However I also tested with Forms 2.3.4-pre6 and the issue appears to be resolved. The message is no longer displayed in the output after removing the item.

## Version Tests
2.3.4-pre6  GOOD   BAD