This might sound like a trivial question, but even here in Stackflow I only have found binding to a simple string collection.
I have a Parent class with two properties Name and Age.
I have a Child class with two properties ChildName and ChildAge.
Within MVVM pattern I am exposing these properties into the ViewModels and additionally I am also adding into the ParentViewModel also an ObservableCollection Children
Therefore the ParentViewModel contains three exposed properties: Name, Age and Children.
//Inside ParentViewModel
public ObservableCollection<ChildViewModel> Children
My Window.xaml is bound to the MainViewModel that is exposing a
public ObservableCollection<ParentViewModel> Parents { get; set; }
The Datagrid is defined like this:
<DataGrid ItemsSource="{Binding Parents}" AutoGenerateColumns="False">
<DataGrid.Columns>
<DataGridTextColumn Header="Name" Binding="{Binding Name}" />
<DataGridTextColumn Header="Age" Binding="{Binding Age}"/>
<DataGridComboBoxColumn Header="Children"
DisplayMemberPath="ChildName"
SelectedValueBinding="{Binding Children.ChildName}"
SelectedValuePath="ChildName"
SelectedItemBinding="{Binding Children}"
>
</DataGridComboBoxColumn>
</DataGrid.Columns>
</DataGrid>
While Name and Age of parents show correctly, I dont see the Children combo box populated. I am confused and frustrated. Please help. :)