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 turn Events into Commands with Behaviors in SfListView?

Platform: Xamarin.Forms |
Control: SfListView |
Published Date: February 28, 2017 |
Last Revised Date: November 27, 2017
Tags: event, mvvm, commands

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.

ADD COMMENT
You must log in to leave a comment
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
Steve
Feb 08, 2019

Any progress?

Reply
Jayaleshwari N [Syncfusion]
Feb 08, 2019

Hi Steve,

 

We have provided Tap Command and Hold Command which is available from our Syncfusion version 16.1.0.24. You can refer the following user guide documentation which provides details about Tap and Hold command.

 

https://help.syncfusion.com/xamarin/sflistview/mvvm#commands

 

Regards,

Jayaleshwari N

Reply

Please sign in to access our KB

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