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
GroupStyle with a HeaderTemplate containing
TextBox to edit the Titles
- a
Button to insert new Uri items --> here is my issue
- an
ItemTemplate containing a TextBox for the image Uris
- outside my
ListView I have a Button to add new Book items to the ObservableCollection<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?
I'm trying to build an app that allows modifying a grouped collection (nested
ObservableCollection) in aListView. I am showing the grouped collection in theListViewusing aCollectionViewSource.I am not yet using the
ObservableGroup/ObservableGroupedCollectionyet, my question is whether they are a viable option.I would like to achieve the following:
Imagine this (simplified example): having an
ObservableCollection<Book>, and everyBookhas aTitle(string) and anObservableCollection<Uri>for some images.I want to add books, edit their title, and also add
Uris of images and edit them.ListView, I haveGroupStylewith aHeaderTemplatecontainingTextBoxto edit theTitlesButtonto insert new Uri items --> here is my issueItemTemplatecontaining aTextBoxfor the imageUrisListViewI have aButtonto add newBookitems to theObservableCollection<Book>With my current solution (
ObservableCollection<Book>withTitleandObservableCollection<Uri>insideBook), I can editBookTitles andUris, but when I add a newUri, theListView doesnot show it because theCollectionViewSourcedoes not notice it, because theObservableCollection<Book>does not emit aCollectionChangedevent.This is being discussed in in this StackOverflow item as well.
Then I found
ObservableGroup/ObservableGroupedCollectionfrom 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?