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

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

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.





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


Click here to download the sample.

Article ID: Published Date: Last Revised Date: Platform: Control:
7822 07/05/2017 11/15/2018 Xamarin.Forms SfListView
Did you find this information helpful?
Add Comment
You must log in to leave a comment

Please sign in to access our KB

or the page will be automatically redirected to 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