2

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));
        });
}
pmbanka
  • 1,902
  • 17
  • 24
seekle
  • 228
  • 2
  • 7
  • Right now this code is incomplete and it won't compile. Can you please provide compilable code in your question showing where you need changes made? – Enigmativity Dec 21 '15 at 06:10

0 Answers0