We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

OnBindingContextChanged method not called in ViewCell

Thread ID:





132940 Sep 29,2017 06:53 AM UTC Oct 2,2017 05:43 AM UTC Xamarin.Forms 1
Tags: SfListView
Mynca Petrova
Asked On September 29, 2017 06:53 AM UTC

I'm having a situation where the onBindingContextChanged method is not called in a ViewCell used in the Syncfusion sfListView through a DataTemplateSelector.
When I use the regular Xamarin.Forms ListView (commented in code below) the OnBindingContextChanged method is called and everything works fine.

Page with sfListView (binding is done by means of a ViewModel):

ItemsSource="{Binding DataList}"
     ItemTemplate="{StaticResource TotalDataTemplateSelector}"

The used DataTemplateSelector:

public class TotalDataTemplateSelector : DataTemplateSelector


     private readonly DataTemplate _detailTotalDataTemplate;
     private readonly DataTemplate _generalTotalDataTemplate;

     public TotalDataTemplateSelector(bool expand)


           _generalTotalDataTemplate = new DataTemplate(typeof(TotalTileViewCell));
_detailTotalDataTemplate = new DataTemplate(typeof(AccordionDetailTotalViewCell));

           _detailTotalDataTemplate.SetValue(AccordionDetailTotalViewCell.ExpandedProperty, expand);


     protected override DataTemplate OnSelectTemplate(object item, BindableObject container)


           if (item is GeneralTotal)
rn _generalTotalDataTemplate;


           if (item is DetailTotal)
               return _detailTotalDataTemplate;



The ViewCell itself is just a regular Xamarin.Forms ViewCell with some stacklayout and labels in it. I need the OnBindingContextChanged method because these viewcell are dynamic and I have to take actions depending on the values of the binded object.

Any ideas why the OnBindingContextChanged method in the code behind of the ViewCell isn't called?

Dinesh Babu Yadav [Syncfusion]
Replied On October 2, 2017 05:43 AM UTC

Hi Peter, 
Thank you for using Syncfusion Products. 
In Xamarin Forms ListView, ViewCell has been internally handled to raise the OnBindingContextChanged event and override method whenever the binding context of item is changed. But in SfListView, we have updated the binding context of the ListViewItem only and it raises the View’s bindingcontext event if loaded in ViewCell  as like below code example in which you can dynamically modify the data for the item. 
Code Example[C#]: 
public IncomingViewCell() 
   this.View.BindingContextChanged += View_BindingContextChanged; 
private void View_BindingContextChanged(object sender, EventArgs e) 
   //Modify the data here 
   var grid = sender as Grid; 
For your reference, we have attached the sample and you can download it from the below link. 
Please let us know if you require further assistance. 
Dinesh Babu Yadav 


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon