我想在我的WPF應用程序中實現2個進度條。一個(ProgressbarDocument)應顯示每個選定文檔的進度,另一個(ProgressbarProcess)應顯示整個過程的進度,包括處理每個選定的文檔。 我的問題是,如果進度條的動畫值爲100,但ProgressbarDocument的動畫未重置並重新啓動,則動畫將停止。 我該怎麼做?C#:爲什麼我的ProgressBar不會運行多次?
double summand = (1/anzahl);
Duration durationdocument = new Duration(TimeSpan.FromSeconds(1));
Duration durationprocess = new Duration(TimeSpan.FromSeconds(anzahl));
DoubleAnimation doubleanimationdocument = new DoubleAnimation(ProgressbarDocument.Value, durationprocess);
DoubleAnimation doubleanimationprocess = new DoubleAnimation(ProgressbarProcess.Value, durationprocess);
for (int j = 0; j <= anzahl; j++)
{
for (int i = 0; i < 100; i++)
{
ProgressbarDocument.Value++;
ProgressbarProcess.Value= summand + ProgressbarProcess.Value;
doubleanimationdocument = new DoubleAnimation(ProgressbarDocument.Value, durationdocument);
doubleanimationprocess = new DoubleAnimation(ProgressbarProcess.Value, durationprocess);
ProgressbarDocument.BeginAnimation(ProgressBar.ValueProperty, doubleanimationdocument);
ProgressbarProcess.BeginAnimation(ProgressBar.ValueProperty, doubleanimationprocess);
}
if(ProgressbarDocument.Value==100)
{
ProgressbarDocument.Value = 0;
ProgressbarDocument.BeginAnimation(ProgressBar.ValueProperty, doubleanimationdocument);
}
}
,你應該有你試圖通過使用調試器單步執行代碼,看看使用> =,而不是== – Sayse
是否'ProgressbarDocument.Value = 0;'被調用? –
只需將您的ProgressbarDocument設置爲100的模數即可。 –