I have a dictionary with few pairs
Dictionary<DateTime, ObservableCollection<Car>>
and I’m changing year of production of a Car, and because Key (DateTime) is a year I need to move this Car from KeyValuePair with old year to KeyValuePair with new year.
so for example, I had two pairs:
1.1.1997 {Car1,Car2}
1.1.1998 {Car3}
and by
Car2.Production = Convert.ToDateTime("1.1.1998");
I need to have
1.1.1997 {Car1}
1.1.1998 {Car3,Car2}
What is the easiest way to achieve that?
It seems like you might want to use a grouped view for this data instead, but here’s a code solution that addresses the question as stated. If you were planning on doing this for more than one property, I’d recommend making Car inherit from DependencyObject or implementing it from INotifyPropertyChanged instead of creating events for each.