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 : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to pass selected row's data to a command?

SfDataGrid provides two events for selection: SelectionChanging and SelectionChanged. It provides the added items and the removed items as arguments in it. You can pass the selected row info to a command in the ViewModel by using the Xamarin.Forms.Behaviors.

Refer the below code example in which a custom behavior for passing the selected row information to ViewModel is defined.

<?xml version="1.0" encoding="utf-8" ?>

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"







    <local:ViewModel x:Name="viewModel" />





      <local:CustomConverter x:Key="gridSelectionChangedEventArgs" />




  <syncfusion:SfDataGrid x:Name="dataGrid"



                     ItemsSource="{Binding OrderInfo}">


      <local:CustomBehavior Command="{Binding SelectionCommand}"

                            Converter="{StaticResource gridSelectionChangedEventArgs}" />





The below code illustrates the command and the call back implementation to get the selected row information.



The below code illustrates the behavior class implementation for the SfDataGrid.




Sample Link:

How to pass selected row info to a command?

Article ID: Published Date: Last Revised Date: Platform: Control:
7388 01/31/2017 01/31/2017 Xamarin.Forms SfDataGrid
Did you find this information helpful?
Add Comment
You must log in to leave a comment

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