Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue31375.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
using System.Windows.Input;

namespace Maui.Controls.Sample.Issues;

[Issue(IssueTracker.Github, 31375, "[Windows] RefreshView Command executes multiple times when IsRefreshing is set to True", PlatformAffected.UWP)]
public class Issue31375 : ContentPage
{
bool _isLoading = false;
Label _textLabel;
int count = 0;

public bool IsLoading
{
get => _isLoading;
set
{
_isLoading = value;
OnPropertyChanged(nameof(IsLoading));
}
}

public ICommand RefreshCommand { get; set; }
public Issue31375()
{
// Create UI elements
var button = new Button { Text = "Click To Refresh", AutomationId = "RefreshButton" };
button.Clicked += Button_Clicked;

_textLabel = new Label() { AutomationId = "CounterLabel" };
_textLabel.Text = count++.ToString();

// Set BindingContext
BindingContext = this;

// Assign command
RefreshCommand = new Command(AddItems);
var refreshView = new RefreshView
{
Margin = 16,
Content = _textLabel,
};
refreshView.SetBinding(RefreshView.IsRefreshingProperty, nameof(IsLoading));
refreshView.SetBinding(RefreshView.CommandProperty, nameof(RefreshCommand));
Content = new StackLayout
{
Children = { refreshView, button }
};
}

void Button_Clicked(object sender, EventArgs e)
{
IsLoading = true;
}

void AddItems()
{
IsLoading = false;
_textLabel.Text = count++.ToString();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues
{
public class Issue31375 : _IssuesUITest
{
public Issue31375(TestDevice device) : base(device)
{
}

public override string Issue => "[Windows] RefreshView Command executes multiple times when IsRefreshing is set to True";

[Test]
[Category(UITestCategories.RefreshView)]
public void VerifyRefreshViewCommandExecution()
{
App.WaitForElement("CounterLabel");
App.Tap("RefreshButton");
Assert.That(App.FindElement("CounterLabel").GetText(), Is.EqualTo("1"));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,10 @@ void OnRefresh(object sender, RefreshRequestedEventArgs args)
CompleteRefresh();
_refreshCompletionDeferral = args.GetDeferral();

if (VirtualView != null)
if (VirtualView != null && !VirtualView.IsRefreshing)
{
VirtualView.IsRefreshing = true;
}
}

void CompleteRefresh()
Expand Down
Loading