简体   繁体   中英

ProgressBar Xamarin Forms not updating

I Have a Progress Bar in my code and is used to wait a long download image.

var  progress = new ProgressBar()
{
    VerticalOptions = LayoutOptions.CenterAndExpand,
    HorizontalOptions = LayoutOptions.CenterAndExpand
};
progress.Progress = 00;

In my saveImage method I have a callback that is implemented like this:`

private async void FileService_ImageSuccess(string url, string path)
{
    double step = (double)count / 100;
    await progress.ProgressTo(step, 800, Easing.Linear);
    count++;
}

But my progress Bar not refreshing the status, I debug my code and step values is correct, what I'm doing wrong?

I am not sure. But can you try this code:

private async void FileService_ImageSuccess(string url, string path)
{
    double step = (double)count / 100;
    await progress.ProgressTo(step, 800, Easing.Linear);
    count++;
    await Task.Yield();
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM