ObservableCollection <T>, consisting of 7 other collections of ObservableCollection <T> s
I will have 7 small “shopping lists,” and then one large one containing all of the 7 small items.
Is it possible to use databind and observablecollection so that everything that is added / removed / changed from small lists is updated in a large list?
public ObservableCollection<ShopItem> MondayShopList{ get; set; } public ObservableCollection<ShopItem> TuesdayShopList{ get; set; } public ObservableCollection<ShopItem> WedensdayShopList{ get; set; } public ObservableCollection<ShopItem> .... public ObservableCollection<ShopItem> TotalShopList { get; set; } I see 3 alternatives for you ...
- implement a composite ObservableCollection. if this does not exist, you can create it by executing
INotifyCollectionChanged - upload all items to the general list and respond to the collection with modified events of the dayweek collections and make updates to the complete collection.
- Make a small architectural change and associate weekday information with ShopItem. Now you can save them all in one list and display the filtered sections of a large list.
You cannot bind nested data collections unless you use the WPF TreeView control that supports hierarchical data binding. If you want to display the contents of child collections, bind them separately to the Ui . The fact that they are children of another is a coding issue and does not have to reflect its exact relation to Ui .
For specific assistance with implementing these scenarios, see this MSDN article.