Xamarin -执行命令后,滑动以刷新仍在的刷新图标

vi4fp9gy  于 2022-12-07  发布在  其他
关注(0)|答案(2)|浏览(138)

我正在使用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放在最后。它不起作用。

ryhaxcpt

ryhaxcpt1#

我怀疑当刷新完成时,您没有更新UI线程上的IsRefreshing属性。

// after your refresh command completes
Device.BeginInvokeOnMainThread (() => {
  scrollControl.IsRefreshing = false;
});
4dbbbstv

4dbbbstv2#

好吧,这个解决方案有点奇怪,我发现它,因为isrefreshing属性是假的,所以我在代码开始时将isrefreshing设置为真,我以为它会自动设置为真,所以我必须自己手动设置,最后它像charm一样工作。

scrollControl.RefreshCommand = RefreshCommand;
        public ICommand RefreshCommand
        {
            get {return new Command(async () => await ContentScrollView_Scrolled()); }
        }
        async Task ContentScrollView_Scrolled()
        {
        scrollControl.isRefreshing = true;
......
        scrollControl.isRefreshing = false;
        }

相关问题