Reputation: 39
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
}
Upvotes: 1
Views: 1082
Reputation: 19743
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.
Upvotes: 1