Hello, I have seen several examples on the internet of progressBar in WPF, but none works.
It appears more does not fill in the values, in fact it fills the values only after running the initial method where it is called.
Source Code:
public partial class Apresentacao_ProgressBar : Window
{
private BackgroundWorker backgroundWorker1 = new BackgroundWorker();
public Apresentacao_ProgressBar()
{
InitializeComponent();
this.Loaded += new RoutedEventHandler(Form1_Shown);
backgroundWorker1.WorkerReportsProgress = true;
backgroundWorker1.DoWork += new DoWorkEventHandler(backgroundWorker1_DoWork);
backgroundWorker1.ProgressChanged += new ProgressChangedEventHandler(backgroundWorker1_ProgressChanged);
}
void Form1_Shown(object sender, EventArgs e)
{
backgroundWorker1.RunWorkerAsync();
}
void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
for (int i = 0; i <= 100; i++)
{
backgroundWorker1.ReportProgress(i);
System.Threading.Thread.Sleep(100);
}
}
void backgroundWorker1_ProgressChanged(object sender, ProgressChangedEventArgs e)
{
PBar.Value = e.ProgressPercentage;
}
}