【发布时间】:2017-02-27 15:03:39
【问题描述】:
我的代码中有一个进度条,用于等待很长的下载图像。
var progress = new ProgressBar()
{
VerticalOptions = LayoutOptions.CenterAndExpand,
HorizontalOptions = LayoutOptions.CenterAndExpand
};
progress.Progress = 00;
在我的 saveImage 方法中,我有一个这样实现的回调:`
private async void FileService_ImageSuccess(string url, string path)
{
double step = (double)count / 100;
await progress.ProgressTo(step, 800, Easing.Linear);
count++;
}
但我的进度条没有刷新状态,我调试我的代码和步骤值是正确的,我做错了什么?
【问题讨论】:
-
你是在 UI 线程上执行的吗?您可以使用 Device.BeginInvokeOnMainThread() 强制这样做
-
这个方法的action参数是什么?
-
那是你想在 UI 线程上执行的代码,通常是: () => { // UI 代码放在这里 }
标签: c# xamarin.android xamarin.forms progress-bar