.NET MAUI RefreshView Events
The Telerik UI for .NET MAUI RefreshView raises events while the user pulls the content, when a refresh starts, and when a refresh completes. Handle these events to track the pull progress, cancel a gesture, or load data.
Pulling
The RefreshView raises the Pulling event while the user pulls the content and before a refresh starts. The Pulling event handler receives the following parameters:
- The
senderargument, which is of typeobject, but can be cast to theRadRefreshViewtype. - A
Telerik.Maui.Controls.RefreshView.RefreshViewPullingEventArgsobject, which provides the following properties:Progress(double)—Gets the normalized progress toward the refresh threshold, from0.0to1.0.Cancel(bool)—Specifies whether to cancel the current pull gesture. After cancellation, the RefreshView continues to handle the gesture.
Refreshing
The RefreshView raises the Refreshing event when a refresh starts. The event also occurs when you start a refresh by setting IsRefreshing to true. The Refreshing event handler receives the following parameters:
- The
senderargument, which is of typeobject, but can be cast to theRadRefreshViewtype. - An
EventArgsobject.
Load the data in the Refreshing event handler, and then set IsRefreshing to false to end the refresh.
Refreshed
The RefreshView raises the Refreshed event when a refresh completes. The Refreshed event handler receives the following parameters:
- The
senderargument, which is of typeobject, but can be cast to theRadRefreshViewtype. - An
EventArgsobject.
Handle the RefreshView Events
The following example demonstrates how to display the pull progress, cancel a pull gesture after half of the pulling threshold, and log the Refreshing and Refreshed events.
-
Define the RefreshView in XAML:
XAML<telerik:RadRefreshView x:Name="refreshView" Grid.Row="1" Pulling="OnPulling" Refreshing="OnRefreshing" Refreshed="OnRefreshed"> <VerticalStackLayout Padding="20" Spacing="10" BackgroundColor="#EEEEEE"> <Label Text="Pull down to raise the Pulling, Refreshing and Refreshed events." /> <Label x:Name="progressLabel" Text="Progress: 0 %" /> </VerticalStackLayout> </telerik:RadRefreshView> -
Define the event handlers:
C#private void OnPulling(object sender, RefreshViewPullingEventArgs e) { this.progressLabel.Text = $"Progress: {e.Progress:P0}"; if (this.cancelCheckBox.IsChecked == true && e.Progress > 0.5) { e.Cancel = true; this.Log("Pulling canceled"); } } private async void OnRefreshing(object sender, EventArgs e) { this.Log("Refreshing"); await Task.Delay(1500); this.refreshView.IsRefreshing = false; } private void OnRefreshed(object sender, EventArgs e) { this.Log("Refreshed"); }
For a runnable example demonstrating the RefreshView events, see the SDKBrowser Demo Application and go to the RefreshView > Events category.