Progressbar in xamarin forms

jonata biondi 21 Reputation points
2021-05-04T17:46:07.607+00:00

Hi
i use Backgroundworker to download files from an ftp
In ui i set a progress bar and a text to report the percentage
The label report correctly the progress insteed progressbar is growing up to 100 in a second

private void Worker_ProgressChanged(object sender, ProgressChangedEventArgs e)
{
            progressBar.Progress = e.ProgressPercentage;

            lblStatus.Text = "Downloading...";

            lblStatus.Text = $"Download  {filesizedownloaded:F2} / {filesize:F2} ({e.ProgressPercentage} % Complete. )";
 }

what i wrong?

Developer technologies .NET Xamarin
{count} votes

Accepted answer
  1. Cole Xia (Shanghai Wicresoft Co,.Ltd.) 6,756 Reputation points
    2021-05-05T07:06:52.143+00:00

    Hello,

    Welcome to Microsoft Q&A!

    ProgressBar.Progress should be set between 0 and 1, but here the value is great than 1, it is treated as 1, this is the reason that it is filled.

    Values less than 0 or larger than 1 will be clamped to the range [0-1].

    Correct your code as below

       progressBar.Progress = e.ProgressPercentage/100;  
    

    Best Regards,
    Cole Xia


    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.