Search code examples
c#wpfviewmodelobservablecollection

Shaping ObservableCollection


I have a really simple question.

I got an ObservableCollection of some ViewModel (with INotifyPropertyChanged) which gets updated frequently.

Now I need to shape the data into a new ObservableCollection of NewViewModel like this;

        var query = from o in _orders
                select new ComplexRowViewModel()
                           {Isin = o.Isin,
                            Name = o.Isin,
                            GermanSymbol = o.Exchange,
                            PrimarySymbol = o.State.ToString()};
        GridData = query;

But of course it doesn't work. Just if I use Obtics or CLINQ, the new collection gets updated if a new item comes into the first collection but if an existing item's properties change, it doesn't get updated in the new collection.

So any ideas?


Solution

  • You should implement INotifyPropertyChange from NewViewModel too. In each of this subscibe the INotifyPropertychange on the source order and raise a new event properly.