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.
Unfortunately, activation email could not send to your email. Please try again.

How to turn Events into Commands with Behaviors in SfListView?

In SfListView, Event can be turned into the Command using Behaviors to follow the MVVM pattern.

To achieve this, need to create a Command for the ItemTapped event of SfListView in ViewModel.

C#

 

And associate that Command to the appropriate Event of SfListView using Behaviors like below.

 

XAML

 

Now, when tapped on the ListViewItem, corresponding Command in ViewModel will be invoked automatically and performed the desired operation as shown in below screenshot.

Screenshot:

Click here to download the sample.

Article ID: Published Date: Last Revised Date: Platform: Control:
7523 02/28/2017 11/27/2017 Xamarin.Forms SfListView
Did you find this information helpful?
Comments
Dave Friedel Oct 29, 2017

To make this a tad more helpful, one should reference the "local:EventToCommandBehavior" which is outlined on this page.  https://developer.xamarin.com/guides/xamarin-forms/application-fundamentals/behaviors/reusable/event-to-command-behavior/

Reply
Dave Friedel Oct 29, 2017

To Be Honest - you should make a Command Property like other vendors.  Make your controls robust as possible to make the developer's lives easier.

Reply
Muthu Kumaran Gnanavinayagam [Syncfusion] Nov 02, 2017

Hi Dave,

 

Thanks for your valuable feedback. We are already have plan to provide Command for the applicable events. This feature is in queue and will implement in any our upcoming release.

 

Regards,

G.Muthu Kumaran.

Reply
Add Comment
You must log in to leave a comment

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.