I checked other links here but I can't really get the right answer. I have xaml which consists of two textboxes. The first is hours while the next is minutes. Whenever I change the value of hours in textbox, minutes should reset to 0. How can I do it with OnPropertyChange
?
public class Variable : INotifyPropertyChanged
{
public Variable()
{
this.hours = "1";
this.minutes = "2";
}
public event PropertyChangedEventHandler PropertyChanged;
private string hours;
private string minutes;
public string Hours
{
get { return this.hours.ToString(); }
set
{
if (this.hours != value)
{
this.hours = value;
this.minutes = "0";
this.OnPropertyChanged("Hours");
}
}
}
public string Minutes { get { return this.minutes; } }
public void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName ));
}
}
this.OnPropertyChanged("Minutes")
after setting minutes to 0.