I have an usercontrol in a UWP who I place in other user controls who have two text TextBlocks who are bound to the VM.
Here is the XAML Code:
DataContext
DataContext="{Binding BalanceView, Source={StaticResource CoreModule}}"
<TextBlock Text="{Binding TotalBalance, Mode=TwoWay, Converter={StaticResource AmountFormatConverter}, UpdateSourceTrigger=PropertyChanged}"
Style="{StaticResource DeemphasizedBodyTextBlockStyle}"
Margin="0,0,5,0" />
<TextBlock Text=" / "
Style="{StaticResource DeemphasizedBodyTextBlockStyle}"
Margin="0,0,5,0" />
<TextBlock Text="{Binding EndOfMonthBalance, Mode=TwoWay, Converter={StaticResource AmountFormatConverter}, UpdateSourceTrigger=PropertyChanged}"
Style="{StaticResource DeemphasizedBodyTextBlockStyle}"
Margin="0,0,5,0" />
And the VM Properties there bound to:
public double TotalBalance
{
get { return totalBalance; }
set
{
if (Math.Abs(totalBalance - value) < 0.01) return;
totalBalance = value;
RaisePropertyChanged();
}
}
public double EndOfMonthBalance
{
get { return endOfMonthBalance; }
set
{
if (Math.Abs(endOfMonthBalance - value) < 0.01) return;
endOfMonthBalance = value;
RaisePropertyChanged();
}
}
public event PropertyChangedEventHandler PropertyChanged;
/// <summary>
/// Raises this object's PropertyChanged event.
/// </summary>
/// <param name="propertyName">The property that has a new value.</param>
protected void OnPropertyChanged(string propertyName)
{
PropertyChangedEventHandler handler = this.PropertyChanged;
if (handler != null)
{
var e = new PropertyChangedEventArgs(propertyName);
handler(this, e);
}
}
I can see that the value returned is correct. But on the UI it's permanently on 0. If I set the value staticly to a value it's shown properly.
What is wrong?