There is a collection (ObservableCollection) A, each object of collection A has a collection B (ObservableCollection). You need to do a Binding for the DataGrid ItemsSource of all B collections, each of which is in an A collection item and you need to remove all items from B that were in A when deleting an item from the A collection. nothing is removed from the datagrid. Also it would be desirable that when adding an element A, DataGrid added all AB
this.B = new ObservableCollection<B>(); this.A.ToList().ForEach(a => aBToList().ForEach(b => this.B.Add(b))); <DataGrid ItemsSource="{Binding B}" AutoGenerateColumns="False"> <DataGrid.Columns> <DataGridTextColumn Width="*" IsReadOnly="True" Header="Data" Binding="{Binding Data}"/> </DataGrid.Columns> </DataGrid>
IEnumerable<B> Bs => As.SelectMany(a => a.Bs);and get attached to it. The mainNotifyPropertyChanged(nameof(Bs))is to add / remove elements inAscallNotifyPropertyChanged(nameof(Bs)), so that View reread this property - Andrey NOP