У меня проблемы с привязкой следующих структур к представлению XAML:
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
Экземпляр SampleViewModel установлен как DataContext для представления.Я связываю коллекцию Child с GridView ItemsSource.В GridView у меня есть ComboBox для страны, и я хочу заполнить его коллекцией стран в SampleViewModel.
<Telerik:RadGridView ItemsSource="{ Binding Child }" ...>
<Telerik:RadGridView.Columns>
<Telerik:GridViewComboBoxColumn DataMemberBinding="{Binding CountryId}"
SelectedValueMemberPath="Id"
DisplayMemberPath="Name"
ItemsSource="{Binding ????}" />
...
...
...
Каким должен быть ItemsSource?Как я могу вернуться к свойствам корневой виртуальной машины внутри ItemsSource = "{Binding Child}"?
Или как мне реструктурировать ViewModel для достижения вышеуказанного?