It would be nice to have support for ICollectionView adding grouping, sorting etc.
@Symbai to give a bit more context to @kekekeks' answer: yes I'd recommend using DynamicData for this (at least for now). ICollectionView is a bottomless well of bugginess and strange behavior (it's what made me give up on the original Avalonia) and I don't really want to port that stuff to the new Avalonia :/
Having said that, I appreciate that we don't really have a great story for grouping at the moment in Avalonia and it's something that DynamicData won't solve by itself. I'd like to think/talk about grouping some more at some point in the near future and see what we want to do there.
We also need some documentation on best practises for doing this stuff with DynamicData.
My previous comment wasn't that great, I apologize. I would like to change the request into providing grouping at least in various controls such as Listbox natively. Even when group / sort using dynamicdata there could still be some visual feedback to the end user and I dont see any way to achieve this myself at this moment.
Hey @Symbai - no problem, your question is totally valid. We don't have any documentation for any of this, and not really any examples either. I think the closest you can find at the moment is https://github.com/RolandPheasant/DynamicData/wiki/Introduction-for-ReactiveUI-users and https://reactiveui.net/docs/handbook/collections/.
As I said, we don't really have a good story for grouping yet - it's definitely something we need to work on.
Thanks for the links. I've been able to group and sort and filter using DynamicData now. For sort I just added two buttons and for filter a textbox. But I have no idea how to add group headers to the Listbox. In WPF the listbox has a group header style but on Avalonia it's missing. Is there a workaround for it?
As I said, we don't really have a good story for grouping yet - it's definitely something we need to work on.
鈽濓笍 this pretty much. We don't have grouping yet in our controls. I think the closest you will be able to come is to display something like a ListBox of ItemsControls with a header. Unfortunately you'll lose virtualisation support.
Another option might be to present a flat list of view models, where each view model is either and ItemViewModel or a HeaderViewModel. You'd then use DataTemplates to display the correctly styled item. However currently it wouldn't be easy to make the headers non-selectable like this.
With DataGridCollectionView and DataGrid added to main Avalonia repo, we received possibilities to display collections with group and sorting support. This can be closed.
Most helpful comment
鈽濓笍 this pretty much. We don't have grouping yet in our controls. I think the closest you will be able to come is to display something like a
ListBoxofItemsControlswith a header. Unfortunately you'll lose virtualisation support.Another option might be to present a flat list of view models, where each view model is either and
ItemViewModelor aHeaderViewModel. You'd then useDataTemplatesto display the correctly styled item. However currently it wouldn't be easy to make the headers non-selectable like this.