Skip to content

Commit

Permalink
Merge pull request unoplatform#15379 from unoplatform/dev/mazi/refres…
Browse files Browse the repository at this point in the history
…h-docs

docs: `RefreshContainer`
  • Loading branch information
jeromelaban authored Feb 6, 2024
2 parents 9d62a25 + be0160a commit c6d040f
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
38 changes: 38 additions & 0 deletions doc/articles/controls/RefreshContainer.md
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>
```
2 changes: 2 additions & 0 deletions doc/articles/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,8 @@
href: controls/Popup.md
- name: ProgressRing
href: features/progressring.md
- name: RefreshContainer (Pull to Refresh)
href: controls/RefreshContainer.md
- name: ScrollViewer
href: controls/ScrollViewer.md
- name: TextBox
Expand Down

0 comments on commit c6d040f

Please sign in to comment.