I have an iNotifyChange property bound to a header in my XAML. What I would like is from code behind to be able to update an int value but have the string returned to the XAML. I.e. code updates property to 6, XAML updates to "Warnings: 6". The problem is that a property's type can't be different to its return type. How should I modify the below to make this work?
<Expander Header="{Binding Path=DATErrorsHeader, UpdateSourceTrigger=PropertyChanged}">
private int _overallError;
public string ErrorsWarningsHeader
{
get { return "Warnings: " + _overallError.ToString(); }
set
{
int.TryParse(value, out _overallError);
NotifyPropertyChanged();
}
}
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void NotifyPropertyChanged([CallerMemberName] String propertyName = "")
{
var handler = PropertyChanged;
if (handler != null)
handler(this, new PropertyChangedEventArgs(propertyName));
}
In code I'm basically doing;
viewModel.ErrorsWarningsHeader = "6";
I would rather this be an int so that I can add onto the property's current value.