I have observableCollection of items, and this collection constantly updates. When the item updates, I would like the group to update as well.
I would need to group this collection, for each group, I create a GroupItem class, and store items in the GroupItem. As item in the original collection changes, I could see that a new group is created, and the modified item is added to the group(groupedItem). So far so good. But I also need this modified item to be removed from its original group. How do I achieve that?
public MyObjectVM(ObservableCollection<Item> source)
{
ObjectsSource = source.CreateDerivedCollection((x => x), _ => true, null, null);
ObjectsSource.ChangeTrackingEnabled = true;
var whenObjectsAddedChanged = Observable
.Merge(ObjectsSource.ItemsAdded,
ObjectsSource.ItemChanged.Select(x => x.Sender));
whenObjectsAddedChanged
.GroupBy(o => o.A)
.Subscribe( group =>
{
var newgroup = new GroupedItem();
GroupedObjects.Add(newgroup);
newgroup.Entries = new ObservableCollection<Item>();
group.Subscribe(i => newgroup.Entries.Add(i));
});
}