我正在使用xamarin表单来开发我的项目,现在我正在使用Jason-Smith组件来刷新我的视图。
Xamarin.Forms-PullToRefreshLayout
我正在使用以下代码:
scrollControl.RefreshCommand = RefreshCommand;
public ICommand RefreshCommand
{
get {return new Command(async () => await ContentScrollView_Scrolled()); }
}
async Task ContentScrollView_Scrolled()
{
......
}
在我执行代码之后,刷新图标仍然在旋转。我试着把scrollControl.isRefreshing = false
放在最后。它不起作用。
我怀疑当刷新完成时,您没有更新UI线程上的IsRefreshing属性。试试这个:
// after your refresh command completes
Device.BeginInvokeOnMainThread (() => {
scrollControl.IsRefreshing = false;
});
好吧,这个解决方案有点奇怪,我发现了它,因为isrefreshing属性是false,所以我在代码开始时将isrefreshng设置为true,我认为它会自动设置为true,所以我必须自己手动,最后它的工作方式就像魅力
scrollControl.RefreshCommand = RefreshCommand;
public ICommand RefreshCommand
{
get {return new Command(async () => await ContentScrollView_Scrolled()); }
}
async Task ContentScrollView_Scrolled()
{
scrollControl.isRefreshing = true;
......
scrollControl.isRefreshing = false;
}