Bug 45936 - On UWP, updating a ViewCell directly has no visual effect
Summary: On UWP, updating a ViewCell directly has no visual effect
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 2.3.4
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2016-10-26 17:45 UTC by John Hardman
Modified: 2017-06-20 11:57 UTC (History)
3 users (show)

Tags: UWP ListView ViewCell Refresh AC
Is this bug a regression?: ---
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 for Bug 45936 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 John Hardman 2016-10-26 17:45:51 UTC
I wrote the code below whilst building a repro sample for another bug. Whilst incomplete for the other bug (I need to add data bindings to sensibly use a view model, and then switch to using RecycleElement), this code shows a problem on UWP. As can be seen in the ViewCell code immediately below, there is a Tapped handler that modifies the contained Label, the StackLayout and the ViewCell itself. However, on UWP, despite that code being executed when the user taps the cell, the displayed representation remains unchanged. Adding further code to force InvalidateMeasure makes no difference.

    public class Bug_InteractiveTextViewCell : ViewCell
        private Label _label;
        private StackLayout _stackLayout;

        public Bug_InteractiveTextViewCell()
            _label = new Label
                InputTransparent = true,
                Text = "ViewCell with IsEnabled = true",
                TextColor = Color.White

            _stackLayout = new StackLayout
                BackgroundColor = Color.Green,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                InputTransparent = true,
                MinimumHeightRequest = 80,
                Padding = new Thickness(15, 12, 15, 12),
                Spacing = 0,
                VerticalOptions = LayoutOptions.CenterAndExpand,
                Children =

            this.View = _stackLayout;

            this.IsEnabled = true;

            this.Tapped += (sender, args) =>
                // None of this has any visible effect on UWP, despite doing so on Android and iOS (on iOS, it requires refreshing by scrolling to get the full effect, which is expected)
                this.View.BackgroundColor = Color.Yellow;
                _stackLayout.BackgroundColor = Color.Yellow;
                _label.BackgroundColor = Color.Yellow;
                _label.Text = "Tapped";

    public class Bug_InteractiveTemplatedView : DataTemplate
        public Bug_InteractiveTemplatedView() :
            base(() => new Bug_InteractiveTextViewCell())
            // no-op

    } // public class Bug_InteractiveTemplatedView : DataTemplate

    public class ViewModelTwo : BaseViewModelForListView
        public static DataTemplate _dataTemplate = new Bug_InteractiveTemplatedView();

        public ViewModelTwo(int index)
            DataTemplate = _dataTemplate;
            IsEnabled = true;
            Index = index.ToString();

    } // public class ViewModelTwo : BaseViewModelForListView

    public class BaseViewModelForListView
        public DataTemplate DataTemplate { get; set; }
        public bool IsEnabled { get; set; }
        public string  Index { get; set; }

    } // public class BaseViewModelForListView

    public class BugTemplateSelector : DataTemplateSelector
        protected override DataTemplate OnSelectTemplate(object item, BindableObject container)
                BaseViewModelForListView bmi = item as BaseViewModelForListView;
                return bmi.DataTemplate;
            catch (Exception ex)
                var v = ex;

    } // public class BugTemplateSelector : DataTemplateSelector

The above is used on a page by simply doing the following and including listView in the content of the page.

            IList<BaseViewModelForListView> listViewModels = new List<BaseViewModelForListView>();
            for (int i = 0; i < 200; ++i)
                listViewModels.Add(new ViewModelTwo(i));

            ListView listView = new ListView(ListViewCachingStrategy.RetainElement)
            listView.ItemTemplate = new BugTemplateSelector();
            listView.ItemsSource = listViewModels;
Comment 1 Paul DiPietro [MSFT] 2017-02-21 19:42:51 UTC
Checked against master/nightly and it still appears to be doing this from what I can tell, despite some changes to ViewCell to fix another bug (40139).