Class SfPullToRefresh
SfPullToRefresh enables interaction to refresh the loaded view. This control allows users to trigger a refresh action by performing the pull-to-refresh gesture.
Inheritance
Implements
Namespace: Syncfusion.Maui.Toolkit.PullToRefresh
Assembly: Syncfusion.Maui.Toolkit.dll
Syntax
public class SfPullToRefresh : PullToRefreshBase, IDrawableLayout, IDrawable, IAbsoluteLayout, ILayout, IView, IElement, ITransform, IContainer, IList<IView>, ICollection<IView>, IEnumerable<IView>, IEnumerable, ISafeAreaView, IPadding, ICrossPlatformLayout, IVisualTreeElement, ISemanticsProvider, ITouchListener, IParentThemeElement, IThemeElement
Constructors
SfPullToRefresh()
Initializes a new instance of the SfPullToRefresh class.
Declaration
public SfPullToRefresh()
Fields
CanRestrictChildTouchProperty
Identifies the CanRestrictChildTouch bindable property.
Declaration
public static readonly BindableProperty CanRestrictChildTouchProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
Remarks
The CanRestrictChildTouchProperty property determines whether touch interactions on child elements should be restricted when the pull-to-refresh action is in progress.
IsRefreshingProperty
Identifies the IsRefreshing bindable property.
Declaration
public static readonly BindableProperty IsRefreshingProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
Remarks
The IsRefreshingProperty property determines whether the pull-to-refresh action is currently active.
ProgressBackgroundProperty
Identifies the ProgressBackground bindable property.
Declaration
public static readonly BindableProperty ProgressBackgroundProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
Remarks
The ProgressBackgroundProperty property determines the background brush of the progress circle displayed during the pull-to-refresh action.
ProgressColorProperty
Identifies the ProgressColor bindable property.
Declaration
public static readonly BindableProperty ProgressColorProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
Remarks
The ProgressColorProperty property determines the color of the progress indicator displayed during the pull-to-refresh action.
ProgressThicknessProperty
Identifies the ProgressThickness bindable property.
Declaration
public static readonly BindableProperty ProgressThicknessProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
Remarks
The ProgressThicknessProperty property determines the thickness of the progress indicator displayed during the pull-to-refresh action.
PullableContentProperty
Identifies the PullableContent bindable property.
Declaration
public static readonly BindableProperty PullableContentProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
Remarks
The PullableContentProperty property determines the content that can be pulled to trigger the refresh action.
PullingThresholdProperty
Identifies the PullingThreshold bindable property.
Declaration
public static readonly BindableProperty PullingThresholdProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
Remarks
The PullingThresholdProperty property determines the distance that needs to be pulled before the refresh action is triggered.
PullingViewTemplateProperty
Identifies the PullingViewTemplate bindable property.
Declaration
public static readonly BindableProperty PullingViewTemplateProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
Remarks
The PullingViewTemplateProperty property determines the template for the view that is displayed while the user is pulling to refresh.
RefreshCommandParameterProperty
Identifies the RefreshCommandParameter bindable property.
Declaration
public static readonly BindableProperty RefreshCommandParameterProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
Remarks
The RefreshCommandParameterProperty property determines the parameter that will be passed to the RefreshCommand when it is executed.
RefreshCommandProperty
Identifies the RefreshCommand bindable property.
Declaration
public static readonly BindableProperty RefreshCommandProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
Remarks
The RefreshCommandProperty property determines the command that will be executed when a refresh is triggered.
RefreshingViewTemplateProperty
Identifies the RefreshingViewTemplate bindable property.
Declaration
public static readonly BindableProperty RefreshingViewTemplateProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
Remarks
The RefreshingViewTemplateProperty property determines the template for the view that is displayed while the pull-to-refresh action is in progress.
RefreshViewHeightProperty
Identifies the RefreshViewHeight bindable property.
Declaration
public static readonly BindableProperty RefreshViewHeightProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
Remarks
The RefreshViewHeightProperty property determines the height of the refresh view that is displayed during the pull-to-refresh action.
RefreshViewThresholdProperty
Identifies the RefreshViewThreshold bindable property.
Declaration
public static readonly BindableProperty RefreshViewThresholdProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
Remarks
The RefreshViewThresholdProperty property determines the threshold distance that needs to be pulled before the refresh action is triggered.
RefreshViewWidthProperty
Identifies the RefreshViewWidth bindable property.
Declaration
public static readonly BindableProperty RefreshViewWidthProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
Remarks
The RefreshViewWidthProperty property determines the width of the refresh view that is displayed during the pull-to-refresh action.
TransitionModeProperty
Identifies the TransitionMode bindable property.
Declaration
public static readonly BindableProperty TransitionModeProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
Remarks
The TransitionModeProperty property determines the type of transition animation that occurs when the pull-to-refresh action is triggered.
Properties
CanRestrictChildTouch
Gets or sets a value indicating whether PullableContent touch interactions should be allowed or not.
Declaration
public bool CanRestrictChildTouch { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | It accepts System.Boolean. The default value is false. |
Remarks
This property allows you to control whether the touch interactions with the PullableContent should be restricted. When set to true, touch interactions with the PullableContent will be restricted.
Examples
Here is an example of how to set the CanRestrictChildTouch property
IsRefreshing
Gets or sets a value indicating whether SfPullToRefresh is in refreshing state.
Declaration
public bool IsRefreshing { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | It accepts System.Boolean. The default value is false. |
Remarks
This property allows you to programmatically start or stop the refreshing state of the SfPullToRefresh control.
Examples
Here is an example of how to set the IsRefreshing property
ProgressBackground
Gets or sets the background of the Syncfusion.Maui.Toolkit.PullToRefresh.SfPullToRefresh.ProgressCircleView.
Declaration
public Brush ProgressBackground { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.Maui.Controls.Brush | It accepts Microsoft.Maui.Controls.Brush. The default background is Color.FromArgb("#F3EDF7"). |
Remarks
This property allows you to customize the background appearance of the progress circle view.
Examples
Here is an example of how to set the ProgressBackground property
ProgressColor
Gets or sets the color of the Syncfusion.Maui.Toolkit.PullToRefresh.SfPullToRefresh.ProgressCircleView.
Declaration
public Color ProgressColor { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.Maui.Graphics.Color | It accepts Microsoft.Maui.Graphics.Color. The default color is Color.FromArgb("6750A4"). |
Remarks
This property allows you to customize the color of the progress circle view displayed during the pull-to-refresh action.
Examples
Here is an example of how to set the ProgressColor property
ProgressThickness
Gets or sets the thickness of the Syncfusion.Maui.Toolkit.PullToRefresh.SfPullToRefresh.ProgressCircleView.
Declaration
public double ProgressThickness { get; set; }
Property Value
Type | Description |
---|---|
System.Double | It accepts System.Double. The default value is 3d. |
Remarks
This property allows you to customize the thickness of the progress circle view.
Examples
Here is an example of how to set the ProgressThickness property
PullableContent
Gets or sets the pullable content of SfPullToRefresh.
Declaration
public View PullableContent { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.Maui.Controls.View | It accepts Microsoft.Maui.Controls.View. The default value is null. |
Remarks
The PullableContent property allows you to specify the content that users can pull down to initiate a refresh action. This content is usually a view such as a Microsoft.Maui.Controls.Label, Microsoft.Maui.Controls.ListView, or any other Microsoft.Maui.Controls.View.
Examples
Here is an example of how to set the PullableContent property
<local:SfPullToRefresh x:Name="pullToRefresh"
PullingThreshold="120"
RefreshViewHeight="30"
RefreshViewThreshold="30"
RefreshViewWidth="30">
<local:SfPullToRefresh.PullableContent>
<Label x:Name="month"
TextColor="White"
HorizontalTextAlignment="Center"
VerticalTextAlignment="Start" />
</local:SfPullToRefresh.PullableContent>
</local:SfPullToRefresh>
PullingThreshold
Gets or sets the maximum pulling Y position of the Syncfusion.Maui.Toolkit.PullToRefresh.SfPullToRefresh.ProgressCircleView.
Declaration
public double PullingThreshold { get; set; }
Property Value
Type | Description |
---|---|
System.Double | It accepts System.Double. The default value is 200d. |
Remarks
This property determines how far the user can pull down before the refresh action is triggered.
Examples
Here is an example of how to set the PullingThreshold property
PullingViewTemplate
Gets or sets the template to be displayed as the refresh content when Pulling.
Declaration
public DataTemplate PullingViewTemplate { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.Maui.Controls.DataTemplate | It accepts Microsoft.Maui.Controls.DataTemplate. The default value is null. |
Remarks
This property allows you to customize the appearance of the refresh view when the user is pulling down to refresh.
Examples
Here is an example of how to set the PullingViewTemplate property
<local:SfPullToRefresh>
<local:SfPullToRefresh.PullingViewTemplate>
<DataTemplate>
<StackLayout>
<Label Text="Pull to refresh..." />
</StackLayout>
</DataTemplate>
</local:SfPullToRefresh.PullingViewTemplate>
</local:SfPullToRefresh>
RefreshCommand
Gets or sets the refresh command for SfPullToRefresh.
Declaration
public ICommand RefreshCommand { get; set; }
Property Value
Type | Description |
---|---|
System.Windows.Input.ICommand | It accepts System.Windows.Input.ICommand. The default value is null. |
Remarks
The command's CanExecute()
method will be triggered when the pulling action is performed.
If false
is returned from CanExecute()
, the pulling will be canceled, and the command will not be executed, and refreshing does not happen.
If true
is returned from CanExecute()
, the command will be executed on refreshing.
Examples
Here is an example of how to set the RefreshCommand property
<local:SfPullToRefresh RefreshCommand="{Binding ViewRefreshCommand}"
RefreshCommandParameter="{Binding .}">
</local:SfPullToRefresh>
RefreshCommandParameter
Gets or sets the parameter of the RefreshCommand.
Declaration
public object RefreshCommandParameter { get; set; }
Property Value
Type | Description |
---|---|
System.Object | It accepts System.Object. The default value is null. |
Remarks
This property allows you to pass additional data to the command when it is executed.
Examples
Here is an example of how to set the RefreshCommandParameter property
<ContentPage>
<local:SfPullToRefresh RefreshCommand="{Binding ViewRefreshCommand}"
RefreshCommandParameter="{Binding .}">
</local:SfPullToRefresh>
</ContentPage>
RefreshingViewTemplate
Gets or sets the template to be displayed as the refresh content on Refreshing.
Declaration
public DataTemplate RefreshingViewTemplate { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.Maui.Controls.DataTemplate | It accepts Microsoft.Maui.Controls.DataTemplate. The default value is null. |
Remarks
This property allows you to customize the appearance of the refresh view when the user is refreshing.
Examples
Here is an example of how to set the RefreshingViewTemplate property
<local:SfPullToRefresh>
<local:SfPullToRefresh.RefreshingViewTemplate>
<DataTemplate>
<StackLayout>
<Label Text="Refreshing..." />
<ActivityIndicator IsRunning="True" />
</StackLayout>
</DataTemplate>
</local:SfPullToRefresh.RefreshingViewTemplate>
</local:SfPullToRefresh>
RefreshViewHeight
Gets or sets the height of the Syncfusion.Maui.Toolkit.PullToRefresh.SfPullToRefresh.ProgressCircleView.
Declaration
public double RefreshViewHeight { get; set; }
Property Value
Type | Description |
---|---|
System.Double | It accepts System.Double. The default value is 48d. |
Remarks
This property is used to set the height of the refresh view that appears when the user pulls down to refresh.
Examples
Here is an example of how to set the RefreshViewHeight property
RefreshViewThreshold
Gets or sets the starting position of the progress circle view in SlideOnTop.
Declaration
public double RefreshViewThreshold { get; set; }
Property Value
Type | Description |
---|---|
System.Double | It accepts System.Double. The default value is 50d. |
Remarks
This property is used to set the threshold at which the refresh view starts appearing when the user pulls down to refresh.
Examples
Here is an example of how to set the RefreshViewThreshold property
RefreshViewWidth
Gets or sets the width of the Syncfusion.Maui.Toolkit.PullToRefresh.SfPullToRefresh.ProgressCircleView.
Declaration
public double RefreshViewWidth { get; set; }
Property Value
Type | Description |
---|---|
System.Double | It accepts System.Double. The default value is 48d. |
Remarks
This property is used to set the width of the refresh view that appears when the user pulls down to refresh.
Examples
Here is an example of how to set the RefreshViewWidth property
TransitionMode
Gets or sets the transition mode of SfPullToRefresh.
Declaration
public PullToRefreshTransitionType TransitionMode { get; set; }
Property Value
Type | Description |
---|---|
PullToRefreshTransitionType | It accepts PullToRefreshTransitionType. The default is SlideOnTop. |
Remarks
In SlideOnTop mode, the progress circle view will be layout over the PullableContent based on pulling progress. In Push mode, the PullableContent will layout below the progress circle view. Both the circle view and PullableContent will be moved based on pulling progress.
Examples
Here is an example of how to set the TransitionMode property
Methods
EndRefreshing()
Ends refreshing the PullableContent and stops the refreshing animation.
Declaration
public void EndRefreshing()
Remarks
This method stops the refreshing animation and sets the internal state to indicate that the refresh has ended.
Examples
The following C# code demonstrates how to use the EndRefreshing() method:
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
}
private void OnRefreshCompleted(object sender, EventArgs e)
{
pullToRefresh.EndRefreshing();
}
}
StartRefreshing()
Starts refreshing the PullableContent and displays the refreshing animation.
Declaration
public void StartRefreshing()
Remarks
This method initiates the refreshing process and displays the refreshing animation. If the control is currently in the pulling state, it will cancel the pulling state before starting the refresh.
Examples
The following C# code demonstrates how to use the StartRefreshing() method:
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
}
private void OnRefreshButtonClicked(object sender, EventArgs e)
{
pullToRefresh.StartRefreshing();
}
}
Events
Pulling
Occurs when the pulling operation is performed.
Declaration
public event EventHandler<PullingEventArgs> Pulling
Event Type
Type |
---|
System.EventHandler<PullingEventArgs> |
Examples
Here is an example of how to register the Pulling event.
SfPullToRefresh pullToRefresh = new SfPullToRefresh();
pullToRefresh.Pulling += OnPullToRefreshPulling;
private void PullToRefresh_Pulling(object? sender, Toolkit.PullToRefresh.PullingEventArgs e)
{
args.Cancel = false;
var progress = args.Progress;
}
See Also
Refreshed
Occurs when the refreshing operation completes.
Declaration
public event EventHandler<EventArgs> Refreshed
Event Type
Type |
---|
System.EventHandler<System.EventArgs> |
Examples
Here is an example of how to register the Refreshed event.
SfPullToRefresh pullToRefresh = new SfPullToRefresh();
pullToRefresh.Refreshed += OnPullToRefreshRefreshed;
private void OnPullToRefreshRefreshed(object sender, EventArgs args)
{
}
See Also
Refreshing
Occurs when the refreshing operation starts.
Declaration
public event EventHandler<EventArgs> Refreshing
Event Type
Type |
---|
System.EventHandler<System.EventArgs> |
Examples
Here is an example of how to register the Refreshing event.
SfPullToRefresh pullToRefresh = new SfPullToRefresh();
pullToRefresh.Refreshing += OnPullToRefreshRefreshing;
private async void OnPullToRefreshRefreshing(object sender, EventArgs args)
{
pullToRefresh.IsRefreshing = true;
await Task.Delay(2000);
pullToRefresh.IsRefreshing = false;
}