diff --git a/src/Controls/src/Core/RefreshView.cs b/src/Controls/src/Core/RefreshView.cs index 1f985f70e7da..fb48d762158c 100644 --- a/src/Controls/src/Core/RefreshView.cs +++ b/src/Controls/src/Core/RefreshView.cs @@ -37,7 +37,6 @@ static void OnIsRefreshingPropertyChanged(BindableObject bindable, object oldVal var refreshView = (RefreshView)bindable; refreshView.Refreshing?.Invoke(bindable, EventArgs.Empty); - refreshView.Command?.Execute(refreshView.CommandParameter); } static object OnIsRefreshingPropertyCoerced(BindableObject bindable, object value) diff --git a/src/Core/src/Core/IRefreshView.cs b/src/Core/src/Core/IRefreshView.cs index 87a36491f380..0e65f38aad15 100644 --- a/src/Core/src/Core/IRefreshView.cs +++ b/src/Core/src/Core/IRefreshView.cs @@ -1,4 +1,5 @@ -using Microsoft.Maui.Graphics; +using System.Windows.Input; +using Microsoft.Maui.Graphics; namespace Microsoft.Maui { @@ -21,5 +22,15 @@ public interface IRefreshView : IView /// The scrollable content to refresh. /// IView Content { get; } + + /// + /// Gets the command to be executed when the refresh is triggered. + /// + ICommand Command { get; } + + /// + /// Gets the parameter to be passed to the command when it is executed. + /// + object CommandParameter { get; } } } diff --git a/src/Core/src/Handlers/RefreshView/RefreshViewHandler.Android.cs b/src/Core/src/Handlers/RefreshView/RefreshViewHandler.Android.cs index 0f5e0f6c6262..d717ab988202 100644 --- a/src/Core/src/Handlers/RefreshView/RefreshViewHandler.Android.cs +++ b/src/Core/src/Handlers/RefreshView/RefreshViewHandler.Android.cs @@ -18,6 +18,7 @@ protected override void ConnectHandler(MauiSwipeRefreshLayout platformView) void OnSwipeRefresh(object? sender, System.EventArgs e) { VirtualView.IsRefreshing = true; + VirtualView.Command?.Execute(VirtualView.CommandParameter); } protected override void DisconnectHandler(MauiSwipeRefreshLayout platformView) diff --git a/src/Core/src/Handlers/RefreshView/RefreshViewHandler.Tizen.cs b/src/Core/src/Handlers/RefreshView/RefreshViewHandler.Tizen.cs index 5e022f9efc62..f6fcc067add8 100644 --- a/src/Core/src/Handlers/RefreshView/RefreshViewHandler.Tizen.cs +++ b/src/Core/src/Handlers/RefreshView/RefreshViewHandler.Tizen.cs @@ -16,6 +16,7 @@ protected override void ConnectHandler(MauiRefreshLayout platformView) void OnRefreshing(object? sender, EventArgs e) { VirtualView.IsRefreshing = true; + VirtualView.Command?.Execute(VirtualView.CommandParameter); } protected override void DisconnectHandler(MauiRefreshLayout platformView) diff --git a/src/Core/src/Handlers/RefreshView/RefreshViewHandler.Windows.cs b/src/Core/src/Handlers/RefreshView/RefreshViewHandler.Windows.cs index b3060a1283a0..e8a6de0acee4 100644 --- a/src/Core/src/Handlers/RefreshView/RefreshViewHandler.Windows.cs +++ b/src/Core/src/Handlers/RefreshView/RefreshViewHandler.Windows.cs @@ -114,21 +114,18 @@ void OnRefresh(object sender, RefreshRequestedEventArgs args) { CompleteRefresh(); _refreshCompletionDeferral = args.GetDeferral(); - - if (VirtualView != null) - VirtualView.IsRefreshing = true; } void OnManipulationDelta(object sender, UI.Xaml.Input.ManipulationDeltaRoutedEventArgs e) { - if (e.PointerDeviceType is UI.Input.PointerDeviceType.Touch) - return; // Already managed by the RefreshContainer control itself - const double minimumCumulativeY = 20; double cumulativeY = e.Cumulative.Translation.Y; if (cumulativeY > minimumCumulativeY && VirtualView is not null && !VirtualView.IsRefreshing) + { VirtualView.IsRefreshing = true; + VirtualView.Command?.Execute(VirtualView.CommandParameter); + } } void CompleteRefresh() diff --git a/src/Core/src/Handlers/RefreshView/RefreshViewHandler.iOS.cs b/src/Core/src/Handlers/RefreshView/RefreshViewHandler.iOS.cs index 4e0975292de1..15feaf950efb 100644 --- a/src/Core/src/Handlers/RefreshView/RefreshViewHandler.iOS.cs +++ b/src/Core/src/Handlers/RefreshView/RefreshViewHandler.iOS.cs @@ -46,6 +46,7 @@ public static void MapIsEnabled(IRefreshViewHandler handler, IRefreshView refres void OnRefresh(object? sender, EventArgs e) { VirtualView.IsRefreshing = true; + VirtualView.Command?.Execute(VirtualView.CommandParameter); } static void UpdateIsRefreshing(IRefreshViewHandler handler) diff --git a/src/Core/src/PublicAPI/net-android/PublicAPI.Unshipped.txt b/src/Core/src/PublicAPI/net-android/PublicAPI.Unshipped.txt index 548fd0fc54d6..76d8e650d38c 100644 --- a/src/Core/src/PublicAPI/net-android/PublicAPI.Unshipped.txt +++ b/src/Core/src/PublicAPI/net-android/PublicAPI.Unshipped.txt @@ -14,6 +14,8 @@ Microsoft.Maui.ICommandMapper.Add(string! key, Syste Microsoft.Maui.ICommandMapper.Add(string! key, System.Action! action) -> void Microsoft.Maui.Handlers.IImageSourcePartSetter Microsoft.Maui.Handlers.IImageSourcePartSetter.SetImageSource(Android.Graphics.Drawables.Drawable? obj) -> void +Microsoft.Maui.IRefreshView.Command.get -> System.Windows.Input.ICommand! +Microsoft.Maui.IRefreshView.CommandParameter.get -> object! Microsoft.Maui.Layouts.FlexBasis.Equals(Microsoft.Maui.Layouts.FlexBasis other) -> bool Microsoft.Maui.Platform.ImageSourcePartLoader.ImageSourcePartLoader(Microsoft.Maui.Handlers.IImageSourcePartSetter! handler) -> void Microsoft.Maui.Platform.ShapeExtensions diff --git a/src/Core/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt b/src/Core/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt index ff3ef725e6b8..5816408dc189 100644 --- a/src/Core/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt +++ b/src/Core/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt @@ -16,6 +16,8 @@ Microsoft.Maui.ICommandMapper.Add(string! key, Syste Microsoft.Maui.ICommandMapper.Add(string! key, System.Action! action) -> void Microsoft.Maui.Handlers.IImageSourcePartSetter Microsoft.Maui.Handlers.IImageSourcePartSetter.SetImageSource(UIKit.UIImage? obj) -> void +Microsoft.Maui.IRefreshView.Command.get -> System.Windows.Input.ICommand! +Microsoft.Maui.IRefreshView.CommandParameter.get -> object! Microsoft.Maui.Layouts.FlexBasis.Equals(Microsoft.Maui.Layouts.FlexBasis other) -> bool Microsoft.Maui.LifecycleEvents.iOSLifecycle.PerformFetch Microsoft.Maui.Platform.ImageSourcePartLoader.ImageSourcePartLoader(Microsoft.Maui.Handlers.IImageSourcePartSetter! handler) -> void diff --git a/src/Core/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt b/src/Core/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt index aed971633aba..b2dd30ff3a19 100644 --- a/src/Core/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt +++ b/src/Core/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt @@ -16,6 +16,8 @@ Microsoft.Maui.ICommandMapper.Add(string! key, Syste Microsoft.Maui.ICommandMapper.Add(string! key, System.Action! action) -> void Microsoft.Maui.Handlers.IImageSourcePartSetter Microsoft.Maui.Handlers.IImageSourcePartSetter.SetImageSource(UIKit.UIImage? obj) -> void +Microsoft.Maui.IRefreshView.Command.get -> System.Windows.Input.ICommand! +Microsoft.Maui.IRefreshView.CommandParameter.get -> object! Microsoft.Maui.Layouts.FlexBasis.Equals(Microsoft.Maui.Layouts.FlexBasis other) -> bool Microsoft.Maui.Platform.ImageSourcePartLoader.ImageSourcePartLoader(Microsoft.Maui.Handlers.IImageSourcePartSetter! handler) -> void Microsoft.Maui.Platform.MauiImageView.MauiImageView(Microsoft.Maui.Handlers.IImageHandler! handler) -> void diff --git a/src/Core/src/PublicAPI/net-tizen/PublicAPI.Unshipped.txt b/src/Core/src/PublicAPI/net-tizen/PublicAPI.Unshipped.txt index b796cbafaa1c..bdc4871615b0 100644 --- a/src/Core/src/PublicAPI/net-tizen/PublicAPI.Unshipped.txt +++ b/src/Core/src/PublicAPI/net-tizen/PublicAPI.Unshipped.txt @@ -14,6 +14,8 @@ Microsoft.Maui.SizeRequest.Equals(Microsoft.Maui.SizeRequest other) -> bool Microsoft.Maui.Handlers.IImageSourcePartSetter Microsoft.Maui.Handlers.IImageSourcePartSetter.SetImageSource(Microsoft.Maui.Platform.MauiImageSource? obj) -> void Microsoft.Maui.Platform.ImageSourcePartLoader.ImageSourcePartLoader(Microsoft.Maui.Handlers.IImageSourcePartSetter! handler) -> void +Microsoft.Maui.IRefreshView.Command.get -> System.Windows.Input.ICommand! +Microsoft.Maui.IRefreshView.CommandParameter.get -> object! override Microsoft.Maui.Layouts.FlexBasis.Equals(object? obj) -> bool override Microsoft.Maui.Layouts.FlexBasis.GetHashCode() -> int override Microsoft.Maui.SizeRequest.Equals(object? obj) -> bool diff --git a/src/Core/src/PublicAPI/net-windows/PublicAPI.Unshipped.txt b/src/Core/src/PublicAPI/net-windows/PublicAPI.Unshipped.txt index d65de1abcc17..f51d0630cdf4 100644 --- a/src/Core/src/PublicAPI/net-windows/PublicAPI.Unshipped.txt +++ b/src/Core/src/PublicAPI/net-windows/PublicAPI.Unshipped.txt @@ -5,6 +5,8 @@ Microsoft.Maui.IApplication.UserAppTheme.get -> Microsoft.Maui.ApplicationModel. Microsoft.Maui.Hosting.MauiApp.DisposeAsync() -> System.Threading.Tasks.ValueTask Microsoft.Maui.Handlers.IImageSourcePartSetter Microsoft.Maui.Handlers.IImageSourcePartSetter.SetImageSource(Microsoft.UI.Xaml.Media.ImageSource? obj) -> void +Microsoft.Maui.IRefreshView.Command.get -> System.Windows.Input.ICommand! +Microsoft.Maui.IRefreshView.CommandParameter.get -> object! Microsoft.Maui.IWindow.TitleBarDragRectangles.get -> Microsoft.Maui.Graphics.Rect[]? Microsoft.Maui.ICommandMapper Microsoft.Maui.ICommandMapper.GetCommand(string! key) -> System.Action? diff --git a/src/Core/src/PublicAPI/net/PublicAPI.Unshipped.txt b/src/Core/src/PublicAPI/net/PublicAPI.Unshipped.txt index f44a342bccd7..d09557e17d56 100644 --- a/src/Core/src/PublicAPI/net/PublicAPI.Unshipped.txt +++ b/src/Core/src/PublicAPI/net/PublicAPI.Unshipped.txt @@ -11,6 +11,8 @@ Microsoft.Maui.ICommandMapper.Add(string! key, Syste Microsoft.Maui.ICommandMapper.Add(string! key, System.Action! action) -> void Microsoft.Maui.Handlers.IImageSourcePartSetter Microsoft.Maui.Handlers.IImageSourcePartSetter.SetImageSource(object? obj) -> void +Microsoft.Maui.IRefreshView.Command.get -> System.Windows.Input.ICommand! +Microsoft.Maui.IRefreshView.CommandParameter.get -> object! Microsoft.Maui.Layouts.FlexBasis.Equals(Microsoft.Maui.Layouts.FlexBasis other) -> bool Microsoft.Maui.Platform.ImageSourcePartLoader.ImageSourcePartLoader(Microsoft.Maui.Handlers.IImageSourcePartSetter! handler) -> void Microsoft.Maui.SizeRequest.Equals(Microsoft.Maui.SizeRequest other) -> bool diff --git a/src/Core/src/PublicAPI/netstandard/PublicAPI.Unshipped.txt b/src/Core/src/PublicAPI/netstandard/PublicAPI.Unshipped.txt index b7cff3959b8b..442143cae18e 100644 --- a/src/Core/src/PublicAPI/netstandard/PublicAPI.Unshipped.txt +++ b/src/Core/src/PublicAPI/netstandard/PublicAPI.Unshipped.txt @@ -11,6 +11,8 @@ Microsoft.Maui.ICommandMapper.Add(string! key, Syste Microsoft.Maui.ICommandMapper.Add(string! key, System.Action! action) -> void Microsoft.Maui.Handlers.IImageSourcePartSetter Microsoft.Maui.Handlers.IImageSourcePartSetter.SetImageSource(object? obj) -> void +Microsoft.Maui.IRefreshView.Command.get -> System.Windows.Input.ICommand! +Microsoft.Maui.IRefreshView.CommandParameter.get -> object! Microsoft.Maui.Layouts.FlexBasis.Equals(Microsoft.Maui.Layouts.FlexBasis other) -> bool Microsoft.Maui.Platform.ImageSourcePartLoader.ImageSourcePartLoader(Microsoft.Maui.Handlers.IImageSourcePartSetter! handler) -> void Microsoft.Maui.SizeRequest.Equals(Microsoft.Maui.SizeRequest other) -> bool diff --git a/src/Core/src/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt b/src/Core/src/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt index f44a342bccd7..d09557e17d56 100644 --- a/src/Core/src/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt +++ b/src/Core/src/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt @@ -11,6 +11,8 @@ Microsoft.Maui.ICommandMapper.Add(string! key, Syste Microsoft.Maui.ICommandMapper.Add(string! key, System.Action! action) -> void Microsoft.Maui.Handlers.IImageSourcePartSetter Microsoft.Maui.Handlers.IImageSourcePartSetter.SetImageSource(object? obj) -> void +Microsoft.Maui.IRefreshView.Command.get -> System.Windows.Input.ICommand! +Microsoft.Maui.IRefreshView.CommandParameter.get -> object! Microsoft.Maui.Layouts.FlexBasis.Equals(Microsoft.Maui.Layouts.FlexBasis other) -> bool Microsoft.Maui.Platform.ImageSourcePartLoader.ImageSourcePartLoader(Microsoft.Maui.Handlers.IImageSourcePartSetter! handler) -> void Microsoft.Maui.SizeRequest.Equals(Microsoft.Maui.SizeRequest other) -> bool