forked from unoplatform/uno
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request unoplatform#15379 from unoplatform/dev/mazi/refres…
…h-docs docs: `RefreshContainer`
- Loading branch information
Showing
2 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
--- | ||
uid: Uno.Controls.RefreshContainer | ||
--- | ||
|
||
# RefreshContainer (Pull to Refresh) | ||
|
||
## Summary | ||
|
||
`RefreshContainer` is used to provide the pull-to-refresh UI functionality primarily for scrollable content. | ||
|
||
The touch-based pull capability is currently available only on Android, iOS and Windows (via WinUI). However, on the other targets you can still manually call the `RequestRefresh()` method to display the refresh UI. | ||
|
||
To handle the refresh, subscribe to the `RefreshRequested` event. You can perform any kind of work in the handler. To use `async/await`, make the method `async`, get the deferral in the beginning of the method, and complete it after all required work is finished: | ||
|
||
```csharp | ||
refreshContainer.RefreshRequested += OnRefreshRequested; | ||
|
||
private async void OnRefreshRequested( | ||
object sender, | ||
RefreshRequestedEventArgs e) | ||
{ | ||
var deferral = e.GetDeferral(); | ||
await Task.Delay(3000); // Do some asynchronous work | ||
deferral.Complete(); | ||
} | ||
``` | ||
|
||
## Android and iOS specifics | ||
|
||
On Android and iOS `RefreshContainer` requires a scrollable element as the child of the control. This can be either a `ScrollViewer` or a list-based control like `ListView`: | ||
|
||
```xml | ||
<RefreshContainer> | ||
<ScrollViewer> | ||
<!-- Your content that should support refresh --> | ||
</ScrollViewer> | ||
</RefreshContainer> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters