I have difficulties in binding the follow structures to XAML View:
public class SampleViewModel : ViewModelBase
{
public ObservableCollection<ChildViewModel> Child { get; set; }
...
public ObservableCollection<Country> Countries { get; set; }
...
}
public class ChildViewModel : ViewModelBase
{
private int _CountryId;
public int CountryId
{
get { return _CountryId; }
set
{
_CountryId = value;
OnPropertyChanged("CountryId");
}
}
...
}
// Country structure is not shown, just an int and string for CountryID
// and Name in this case
Instance of SampleViewModel is set as DataContext of a View. I bind the collection Child to a GridView ItemsSource. In the GridView I have a ComboBox for Country and I want to populate it with Countries collection in the SampleViewModel.
<Telerik:RadGridView ItemsSource="{ Binding Child }" ...>
<Telerik:RadGridView.Columns>
<Telerik:GridViewComboBoxColumn DataMemberBinding="{Binding CountryId}"
SelectedValueMemberPath="Id"
DisplayMemberPath="Name"
ItemsSource="{Binding ????}" />
...
...
...
What should be the ItemsSource ? How can I go back to root VM's properties inside a ItemsSource="{ Binding Child }" ?
Or how should I restructure the ViewModel to achieve the above ?