Bug 52668 - Button BackgroundColorProperty binding in Custom Cell of ListView not working
Summary: Button BackgroundColorProperty binding in Custom Cell of ListView not working
Alias: None
Product: Forms
Classification: Xamarin
Component: Android ()
Version: 2.3.3
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2017-02-22 16:26 UTC by David Ortinau [MSFT]
Modified: 2017-03-27 14:28 UTC (History)
4 users (show)

Tags: android, listview, binding, button ac
Is this bug a regression?: Yes
Last known good build:

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 David Ortinau [MSFT] 2017-02-22 16:26:11 UTC
From http://stackoverflow.com/questions/42388775/xamarin-forms-customcell-in-listview-button-background-binding-not-working

I have a shared Xamarin.Forms project, and the problem only exists on Android. My problem is, that I have a listview, and when I click a button in my customcell, it changes color(from blue to green). Then I click another button which opens another page, and when I close that page, the item is removed from the listview. But now the item below the removed one, has a green button, instead of a blue.
Here's an example:

1. First image - Showing the ListView with a customcell inside containing information and 2 buttons, notice that they are blue.

[![enter image description here][1]][1]

2. Second image - Showing that I have pressed the first button, and it has now turned green.

[![enter image description here][2]][2]

3. Thrid image - Showing the page that is pushed when I press the second button.

[![enter image description here][3]][3]

4. Fourth image - Now I have clicked the "Bekræft" button on the image before, and the Message has been sent to the Listview page to remove the RouteElement from the list (and so it does). But now the first button is green, even though it has not been pressed.

[![enter image description here][4]][4]

The RouteElement Model.

<!-- language: lang-cs -->

     public class RouteElement : INotifyPropertyChanged
        string arrivalBtnColor;
        public event PropertyChangedEventHandler PropertyChanged;
        public DateTime ArrivalTime { get; set; }
        public DateTime DepartureTime { get; set; }
        public bool ReadyForService { get; set; }
        public bool DeliveredToService { get; set; }
        public string ArrivalBtnBColor
            get { return arrivalBtnColor; }
                if (arrivalBtnColor != value)
                    arrivalBtnColor = value;
        public RouteElement()
            this.ArrivalBtnBColor = "Default";
        protected virtual void OnPropertyChanged(string propertyName)
            if (PropertyChanged != null)
                    new PropertyChangedEventArgs(propertyName));

The CustomCell 

<!-- language: lang-cs -->

    Button ArrivalBtn = new Button
        Text = "Ankomst",
        FontSize = 24,
        BorderRadius = 10,
        HeightRequest = 75,
        TextColor = Color.FromHex("#FFFFFF")
     ArrivalBtn.SetBinding(Button.BackgroundColorProperty, "ArrivalBtnBColor",BindingMode.Default, new StringToColorConverter(), null);

Then I call this MessagingCenter function to remove, from another page in the navigation.

<!-- language: lang-cs -->

    MessagingCenter.Subscribe<RouteElement>(this, "Refresh",(sender) =>
       RouteElement r = (RouteElement)sender;

And now the button of the second RouteElement is green, even though it's supposed to be blue. Any help is much appreciated! 

This "bug" happens only on Android with the newest package of Xamarin.Forms

<!-- language: lang-xml -->

    <package id="Xamarin.Forms" version="" targetFramework="monoandroid70" />

It works fine on Android with this package of Xamarin.Forms

<!-- language: lang-xml -->

    <package id="Xamarin.Forms" version="" targetFramework="monoandroid70" />

  [1]: https://i.stack.imgur.com/rMIEv.png
  [2]: https://i.stack.imgur.com/GCReE.png
  [3]: https://i.stack.imgur.com/T1NSH.png
  [4]: https://i.stack.imgur.com/kgurO.png
Comment 2 Chris King 2017-03-14 16:43:51 UTC
To mark a bug verified we need to observe the behavior on the latest version of XF. To do that, a project with a repo must have been created and run against the latest version. When we confirm a bug let's be sure to attach that project reproduction.
Comment 3 David Ortinau [MSFT] 2017-03-27 14:28:35 UTC
Given we aren't going to have a repro and it appears the issue was resolved with caching strategy changes, I'm going to close this.