diff --git a/src/Controls/src/Core/ListView/ListView.cs b/src/Controls/src/Core/ListView/ListView.cs index 73e14502dd54..aad2d174a91f 100644 --- a/src/Controls/src/Core/ListView/ListView.cs +++ b/src/Controls/src/Core/ListView/ListView.cs @@ -358,7 +358,7 @@ public void BeginRefresh() if (!RefreshAllowed) return; - SetValue(IsRefreshingProperty, true); + SetValue(IsRefreshingProperty, true, SetterSpecificity.FromHandler); OnRefreshing(EventArgs.Empty); ICommand command = RefreshCommand; @@ -368,7 +368,7 @@ public void BeginRefresh() /// public void EndRefresh() { - SetValue(IsRefreshingProperty, false); + SetValue(IsRefreshingProperty, false, SetterSpecificity.FromHandler); } public event EventHandler ItemAppearing; diff --git a/src/Controls/tests/Core.UnitTests/ListViewTests.cs b/src/Controls/tests/Core.UnitTests/ListViewTests.cs index 263336407e29..54dbffc973e8 100644 --- a/src/Controls/tests/Core.UnitTests/ListViewTests.cs +++ b/src/Controls/tests/Core.UnitTests/ListViewTests.cs @@ -1323,6 +1323,38 @@ public void SendRefreshing() Assert.True(lv.IsRefreshing); } + [Fact] + public void SendRefreshingCanBind() + { + var lv = new ListView(); + MockViewModel vm; + lv.BindingContext = vm = new MockViewModel(); + lv.SetBinding(ListView.IsRefreshingProperty, nameof(MockViewModel.Boolean), mode: BindingMode.OneWay); + + bool isRefreshing = false; + lv.PropertyChanged += (sender, arg) => + { + if (arg.PropertyName == ListView.IsRefreshingProperty.PropertyName) + isRefreshing = !isRefreshing; + }; + + //pull down to refresh + IListViewController controller = lv; + controller.SendRefreshing(); //called by renderer + Assert.True(isRefreshing); + Assert.True(lv.IsRefreshing); + + //start to execute command + vm.Boolean = true; + Assert.True(isRefreshing); + Assert.True(lv.IsRefreshing); + + //stop refresh after finish command + vm.Boolean = false; + Assert.False(isRefreshing); + Assert.False(lv.IsRefreshing); + } + [Fact] public void RefreshCommand() { diff --git a/src/Controls/tests/Core.UnitTests/MockViewModel.cs b/src/Controls/tests/Core.UnitTests/MockViewModel.cs index 4781e3049775..b143869f07db 100644 --- a/src/Controls/tests/Core.UnitTests/MockViewModel.cs +++ b/src/Controls/tests/Core.UnitTests/MockViewModel.cs @@ -26,6 +26,20 @@ public virtual string Text } } + bool _boolean; + public virtual bool Boolean + { + get { return _boolean; } + set + { + if (_boolean == value) + return; + + _boolean = value; + OnPropertyChanged("Boolean"); + } + } + protected void OnPropertyChanged([CallerMemberName] string propertyName = null) { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));