-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
I'm trying to build an app that allows modifying a grouped collection (nested ObservableCollection) in a ListView. I am showing the grouped collection in the ListView using a CollectionViewSource.
I am not yet using the ObservableGroup / ObservableGroupedCollection yet, my question is whether they are a viable option.
I would like to achieve the following:
- edit the group names
- edit the individual items
- add / remove new groups
- add / remove individual items
Imagine this (simplified example): having an ObservableCollection<Book>, and every Book has a Title (string) and an ObservableCollection<Uri> for some images.
I want to add books, edit their title, and also add Uris of images and edit them.
- Inside my
ListView, I have- a
GroupStylewith aHeaderTemplatecontainingTextBoxto edit theTitles- a
Buttonto insert new Uri items --> here is my issue
- an
ItemTemplatecontaining aTextBoxfor the imageUris
- a
- outside my
ListViewI have aButtonto add newBookitems to theObservableCollection<Book>
With my current solution (ObservableCollection<Book> with Title and ObservableCollection<Uri> inside Book), I can edit Book Titles and Uris, but when I add a new Uri, the ListView does not show it because the CollectionViewSource does not notice it, because the ObservableCollection<Book> does not emit a CollectionChanged event.
This is being discussed in in this StackOverflow item as well.
Then I found ObservableGroup / ObservableGroupedCollection from Windows Community Toolkit, but I'm unsure whether that will solve my issue? Since the Key is immutable I assume they won't let me edit the Book Titles?