kstanoev
4/22/2015 - 2:30 PM

A code snippet that demonstrates how to enable pull-to-refresh functionality inside the ListView

A code snippet that demonstrates how to enable pull-to-refresh functionality inside the ListView

<!-- ListView declaration in XAML -->
<telerik:RadListView x:Name="listView" IsPullToRefreshEnabled="True">
	<telerik:RadListView.Commands>
		<local:PullToRefreshCommand />
	</telerik:RadListView.Commands>
</telerik:RadListView>

// Implementation of the PullToRefreshCommand
public class PullToRefreshCommand : ListViewCommand
{
	public PullToRefreshCommand()
	{
		this.Id = CommandId.RefreshRequested;
	}
	
	public override bool CanExecute(object parameter)
	{
		return true;
	}

	public override void Execute(object parameter)
	{
		base.Execute(parameter);
		this.Owner.CommandService.ExecuteDefaultCommand(this.Id, parameter);
		
		// fetch items here

		// Stop the pull-to-refresh behavior
		this.Owner.IsPullToRefreshActive = false;
	}
}