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

Accessing ListView item from within the ViewCell

Thread ID:





131650 Jul 21,2017 04:13 AM UTC Jul 24,2017 12:13 PM UTC Xamarin.Forms 2
Tags: SfListView
Asked On July 21, 2017 04:13 AM UTC

Hello!  I am going to try to explain what I am trying to achieve and maybe you can point me in the right direction.  I have an sfListView populated with ViewCells.  Also, I have a ListViewSelectionChanged event to change the appearance of the ViewCell when it is selected.  Within the ViewCell, there is an Entry view.   I would like to change the appearance of the ViewCell (basically call ListViewSelectionChanged), when the Entry text is changed.  I assume I would need to add an myEntry.TextChanged event, but within the TextChanged event, how do I access the listview item to change it to IsSelected = true?

Replied On July 22, 2017 07:58 PM UTC

I figured it out - it was right in front of me.  I just needed to declare my sfListView as public static sfListView listView. 

Dinesh Babu Yadav [Syncfusion]
Replied On July 24, 2017 12:13 PM UTC

Hi Tommy, 
Thank you for using Syncfusion Products. 
You can also achieve the reported requirement “Changing the background color of View in SfListView” by using BindingContext of the Entry which will be the Model object(Example: Contacts). In the Model class, you need to have IsSelected property and bind it to the CustomView as like below code snippet. So, when the entry text is changed, set the IsSelected property as “True” and the respective CustomView’s converter will be triggered and based on the IsSelected value, you can change the appearance of the view. In the sample, we have changed the background color when the IsSelected property is “true”. 
Code Example[XAML]: 
        <Grid x:Name="grid" RowSpacing="1"  
              BackgroundColor="{Binding IsSelected, 
                               Converter={StaticResource customconverter}}"> 
           <Entry TextChanged="Entry_TextChanged" VerticalOptions="Center"  
                  HorizontalOptions="Center" HeightRequest="50"/> 
Code Example[C#]: 
private void Entry_TextChanged(object sender, TextChangedEventArgs e) 
  var entry = sender as Entry; 
  var contact = entry.BindingContext as Contacts; 
  if (e.NewTextValue != "") 
     contact.IsSelected = true; 
     contact.IsSelected = false; 
public class CustomConverter : IValueConverter 
  public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 
    if ((bool)value) 
       return Color.FromHex("#d3d3d3"); 
    return Color.White; 
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