)
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: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to display Selection background on SelectedItem when BackgroundColor is set for view in ItemTemplate?

Platform: Xamarin.Forms |
Control: SfListView |
Published Date: July 5, 2017 |
Last Revised Date: November 15, 2018

In SfListView, the item background color will not be displayed for the selected item if the background color is defined for DataTemplate and this is the actual behavior in framework. However, it can be achieved through a work around by defining a property in data model and using a custom converter.

In the model class, define a IsSelected property which indicates whether the item is selected or not and it will have updated when the selection is performed using the SelectionChanged event. Based on this property, you can change the background color of View defined in the ItemTemplate property by custom converter class.

C#

 

XAML

 

You can change the background color of the view based on the IsSelected property using the SelectionBoolToBackgroundColorConverter class.

 

Click here to download the sample.

2X faster development

The ultimate Xamarin UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

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

Up arrow icon

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

Live Chat Icon For mobile
Live Chat Icon