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. Image for the cookie policy date

How to implement the PullToRefreshCommand?

i can't set up the PullToRefreshCommand like described in the Example:

//Enable PullToRefresh in SfDataGrid
dataGrid.AllowPullToRefresh = true;
dataGrid.PullToRefreshCommand = new Command(ExecutePullToRefreshCommand);
I got an error for Command: CS0246  C# The type or namespace name could not be found (are you missing a using directive or an assembly reference?) 
Do i need another assembly or what am i doing wrong?


2 Replies

EC Eray Cakal August 18, 2016 07:38 AM UTC

Solved by implementing the Interface


DS Divakar Subramaniam Syncfusion Team August 18, 2016 10:19 AM UTC

Hi Eray,   
   
Thank you for contacting Syncfusion Support.   
   
In Xamarin.Forms, there is an in-build class called Command which you can use it. However, in Xamarin.iOS there is no such class and you need to write a command implementing from the ICommand interface in your sample in order to use commands in Xamarin.iOS.   
   
Please refer the below code example for the Command class implementation.     
   
//Enable PullToRefresh in SfDatagrid   
dataGrid.AllowPullToRefresh = true;   
dataGrid.PullToRefreshCommand = new Command (ExecuteCommand);   
   
//Command.cs   
public class Command : ICommand   
{   
    private Action execute;   
    private bool canExecute = true;   
   
    public event EventHandler CanExecuteChanged;   
   
    public Command(Action action)   
    {   
        execute = action;   
    }   
   
    public bool CanExecute(object parameter)   
    {   
        return canExecute;   
    }   
   
    public void Execute(object parameter)   
    {   
        changeCanExecute(true);   
        execute.Invoke();   
    }   
   
    private void changeCanExecute(bool canExecute)   
    {   
        this.canExecute = canExecute;   
        if (CanExecuteChanged != null)   
            CanExecuteChanged(thisnew EventArgs());   
    }   
}   
  
 
We have also included the code in our UG as well and it will be refreshed in live shortly. You can refer it below UG link,   
 
Regards, 
Divakar.  


Loader.
Up arrow icon