1

I have a situation where I need to monitor and react to changes to objects in a dictionary.

class Order
{
  string Ordernumber;
  string Orderstate;
  int Shares;
  decimal Price;
}

For Example:

Dictionary<string, Order> OrderData = new Dictionary<string, Order>

When for example OrderState changes in the Order Class what would be the best way to raise a property change for that specific entry in the Dictionary?

Thanks

Valmorgal
  • 109
  • 9
  • 1
    Check out this [thread](http://stackoverflow.com/questions/5663395/net-observabledictionary) A custom observable dictionary is what you are looking for. This will allow you to monitor collection and it's object state without implementing `INotifyPropertyChanged` interface. – vendettamit Feb 25 '16 at 21:23
  • @vendettamit Thanks that's pretty much what I was looking for. :) – Valmorgal Feb 25 '16 at 23:34
  • @vendettamit For sure! Thanks again. – Valmorgal Mar 01 '16 at 22:17

2 Answers2

0

You can implement INotifyPropertyChanged interface for Order as described in this article: https://msdn.microsoft.com/en-us/library/system.componentmodel.inotifypropertychanged(v=vs.110).aspx

0

A custom observable dictionary is what you are looking for. And There's no built-in observable dictionary available. So you need to write down few bits. Check out this answer for implementation of Observable dictionary.

The custom dictionary will allow you to monitor collection and it's object state without implementing INotifyPropertyChanged interface.

Community
  • 1
  • 1
vendettamit
  • 14,315
  • 2
  • 32
  • 54