I am trying to update my progressbar by using data bindings. The XAML file contains the progressbar:
<ProgressBar Height="23" Name="progressBar" VerticalAlignment="Bottom" Margin="207,444,0,0" Minimum="0" Maximum="{Binding ProgressBarMax}" Value="{Binding ProgressBarValue}" />
My relevant C# class contains the getter & setter:
private int progressBarMax;
public int ProgressBarMax
{
get
{
if (this.progressBarMax == 0)
this.progressBarMax = 1;
return this.progressBarMax;
}
set
{
this.progressBarMax = value;
}
}
private int progressBarValue;
public int ProgressBarValue
{
get
{
return progressBarValue;
}
set
{
progressBarValue = value;
}
}
In my “update” method the maximum is being set. For example like this.progressBarMax = 100;. In a loop the progressbar value is getting the value += 1. To see the updates I used Application.DoEvents(), later I will implement threads. The data binding has to be correct, because I have other components that work fine.
So why doesn’t my progressbar update?
Thank you for your help.
I found the mistake in my code. Unfortunately I changed my private members, not the public properties. So when using
this.ProgressBarValue += 1;instead ofthis.progressBarValue += 1;everything works fine.