문제

As shown in the screenshot, my ProgressBar1.Value updates properly, but not my TaskbarItemInfo.ProgressValue:

enter image description here

This is the code I am using to update both:

void bw_ProgressChanged(object sender, ProgressChangedEventArgs e)
{
    // Set the Value porperty when progress changed.
    this.ProgressBar1.Value = (double)e.ProgressPercentage;

    this.TaskbarItemInfo.ProgressState = TaskbarItemProgressState.Normal;
    this.TaskbarItemInfo.ProgressValue = e.ProgressPercentage / 100;
}

How can I make my TaskbarItemInfo update properly?

도움이 되었습니까?

해결책

this.TaskbarItemInfo.ProgressValue = e.ProgressPercentage / 100;

It looks to me that you are dividing an int with another int therefore the result will be an int when a double is expected.

Simply try to suffix 100 with a "d" (making it a double) :

this.TaskbarItemInfo.ProgressValue = e.ProgressPercentage / 100d;

다른 팁

I would do the following:

TaskbarItemInfo.ProgressValue = ProgressBar1.Value /(double)ProgressBar1.Maximum;

This ensures that the taskbar progress mirrors the progressbar's, even if Maximum is set to something other than 100.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top