This is little hard to explain but I will try my best. I have a ViewModel object which contains two collections.
public class ParentViewModel
{
public ObservableCollection<Child1> ChildCollection1 {get;set;}
public ObservableCollection<Child2> ChildCollection2 { get;set; }
}
In the XAML view file the datacontext is set as shown below:
// populate the child1 and child 2 collections
this.DataContext = ParentViewModel;
In the XAML code everything is inside the DataGrid control. The ItemsSource for the DataGrid control is set as Child1Collection since the child objects has some fields that needed to be shown in most of the datagrid columns. In one of the columns of the DataGrid is a ListBox control. I want that ListBox control to use Child2Collection as ItemsSource.
How can I do that?
DataGrid
needs just 1 collection, however each item (in the collection) may have another collection, ... That means it depends on how you want to fill theListBox
withChildCollection2
for each item inChildCollection1
. - King King