Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to reset ProgressBar

Tags:

c#

wpf

I am experimenting a behavior which makes me crazy.

I have a ProgressBar which represents the evolution of an import in database (in percents, from 0 to 100).

After the import is done (ProgressBar.Value = 100.0), I open a log window with a code which looks like this :

RadWindow window = new RadWindow()
{
    //Set some properties
};
window.Closed += Log_Closed;
window.ShowDialog();

After the RadWindow is closed, I want to reset the ProgressBar. As you can see I use the function Log_Closed whose code is bellow :

private void Log_Closed(object sender, EventArgs e)
{
    //pbImport.Value = pbImport.Minimum; (didn't work)
    pbImport.Value = 0;
}

Note : pbImport is my progress bar.

The instruction in Log_Closed has no effect.


Before instruction :

Before Instruction


After instruction :

After Instruction


Obviously, the progress bar is not updated in UI. I can't understand this. Thank you for your help.

like image 831
Chostakovitch Avatar asked Apr 30 '15 14:04

Chostakovitch


1 Answers

Animations hold onto properties, in order to reset them in code, you have to remove the animation first so that the property is "released".

See https://msdn.microsoft.com/en-us/library/aa970493%28v=vs.110%29.aspx for information on how to set a property after an animation in WPF.

like image 147
Ron Beyer Avatar answered Oct 04 '22 03:10

Ron Beyer