In my ViewModel I have two properties type of Datetime. They are bound in XAML with TwoWay mode. When I update each of them - OnPropertyChanged raises in set part of this Datetime property for the third property. So I want to update the third property only once when I update two Datetime properties at the same time, instead of updating third property twice. How it can be archieved? Code applied:
//1
public DateTime StartDate
{
...
set
{
this.selectedEndDate = value;
this.OnPropertyChanged("StartDate");
this.OnPropertyChanged("MyList");
}
}
//2
public DateTime EndDate
{
...
set
{
this.selectedEndDate = value;
this.OnPropertyChanged("EndDate");
this.OnPropertyChanged("MyList");
}
}
//third property
public IEnumerable<MyObject> MyList
{
get
{
return _data.Where(kvp=> kvp.Key.Date >= Start && kvp.Value.Date <= End).Select(kvp => kvp.Value);
}
}