1

Hello i have a requirement of using progress bar in wpf in which i should associate the progress bar with my code , i.e., when i click an import button i have some if conditions and classes to be executed for that it is taking some time so i want a progress bar that shows my user how much percent have been completed please help my query looking for genuine help.

{
Microsoft.Win32.OpenFileDialog selectExcel = new Microsoft.Win32.OpenFileDialog();
            selectExcel.Filter = "Excel Files|*.xlsm";
            MSAccessOperations accessOperations = new MSAccessOperations();

            Nullable<bool> result = selectExcel.ShowDialog();
            if (result == true)
            {

                string excelFilename = selectExcel.FileName;
             // Here i want to start my progress bar

                if (excelFilename.Contains("NHE PLUS File"))
                    accessOperations.ReadNHEXlsmFile(excelFilename);
                else if (excelFilename.Contains("Total Build File"))
                    accessOperations.ReadTBXlsmFile(excelFilename);
            // Here i want to complete the progress bar
}

1 Answer 1

1

You are only showing the code you use to open the file.
What have you tried regarding the progress bar?

To do a progress bar in WPF, add a ProgressBar element in your UI (XAML):

<ProgressBar x:Name="progress" Minimum="0" Maximum="100" />

Then, update its value in code:

progress.Value = 50;

MSDN Documentation and tutorial.

The difficulty here will be getting the progress information from your Read...File() methods. You may have to refactor your MSAccessOperations class to fire events indicating the progress. But this is unrelated to WPF.

Sign up to request clarification or add additional context in comments.

1 Comment

agree with Xavier, you need to keep updating the progress bar value with reference to your backend code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.