Failed to reset ProgressBar
I am experimenting with behaviors that make me crazy.
I have ProgressBar
one that represents the evolution of imports in the database (percentage from 0
to 100
).
After import ( ProgressBar.Value = 100.0
) is complete, I will open a log window with code that looks like this:
RadWindow window = new RadWindow()
{
//Set some properties
};
window.Closed += Log_Closed;
window.ShowDialog();
After closing, RadWindow
I want to reset ProgressBar
. As you can see, I am using a function Log_Closed
whose code is below:
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 Log_Closed
does not work.
Before instruction:
After the instruction:
Obviously, the progress bar is not being updated in the UI. I do not understand this. Thank you for your help.
source to share
Animations are stored in properties, to reset them in code, you must first remove the animation for the property to be "released".
See https://msdn.microsoft.com/en-us/library/aa970493%28v=vs.110%29.aspx for information on how to set a property after animation in WPF.
source to share
Resetting the progress bar can be achieved by using an if loop and increasing the progress bar.
You can set a bool value for the database process and then simply:
private void Log_Closed(object sender, EventArgs e)
{
//pbImport.Value = pbImport.Minimum; (didn't work)
pbImport.Value = 0;
if (database)
{
pbImport.Increment(100);
}
}
source to share