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:

Before Instruction


After the instruction:

After Instruction


Obviously, the progress bar is not being updated in the UI. I do not understand this. Thank you for your help.

+3


source to share


2 answers


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.

+7


source


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);
    }
}

      

0


source







All Articles