0

In a WPF project I've a shared class called OrderHoder which is simething as

Dictionary<int,OrderBase> OrderList {get;set;}

This dictionary is filled realtime with new data, updates,deletes and so on via a TCP connection and a supersocket-based library.

I've 4 different views that display a Gridview based on a specific type of OrderBase

 public class ForeignOrders: OrderBase
{ omiss}

I wish to have each gridview to get data from that OrderHolder based on a property defined in OrderBase so for ForeignView I've only the items of type ForeignOrder

For the initial load I've got no problem since I use a LINQ query to extract data

OrderList.Select(x=>x.Type == "foreign").ToList()

but this leads me to a problem : I can't get aware that way of OrderList modifications .

Is there a way I can have a projection of a Dictionary so that I can catch the updates/insert/delete?

Before you ask I can't just use a List since I have to know on update/delete what item to change and I can't do a

var idx = OrderList.IndexOf(x=>x.Id = 1234)
OrderList.ElementAt(idx) = [newItem]

I forgot to say It's on a WPF application that uses caliburn micro

advapi
  • 3,661
  • 4
  • 38
  • 73

1 Answers1

1

The class holding OrderList must implement INotifyPropertyChanged

Then you must call the holding class's OnPropertyChanged method each time you alter your dictionary for your control to be aware that the dictionary actually changed and that it must refresh it's display.

For your subclasses to be aware of the OrderList modifications you just have to make them subscribe to the PropertyChanged event of the OrderList holder class

Irwene
  • 2,807
  • 23
  • 48