Thanks
Scott
<telerik:RadGridView x:Name="radGrid" Margin="5,5,5,5" ItemsSource="{Binding PersonViews}" RowIndicatorVisibility="Collapsed" AutoGenerateColumns="False" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" FontSize="14">
<telerik:RadGridView.Columns>
<telerik:GridViewDataColumn DataMemberBinding="{Binding Name}" Header="Name" />
<telerik:GridViewDataColumn DataMemberBinding="{Binding Location}" Header="Location"/>
<telerik:GridViewComboBoxColumn ItemsSourceBinding="{Binding Occupation}"
UniqueName="Uniq"
SelectedValueMemberPath="ID"
DisplayMemberPath="Occupation" Header="Occupation"/>
</telerik:RadGridView.Columns>
</telerik:RadGridView>
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
using
System.ComponentModel;
using
System.Collections.ObjectModel;
namespace
GridComboBindingTest
{
class GridViewModel : INotifyPropertyChanged
{
private ObservableCollection<PersonView> _personViews;
public GridViewModel()
{
PersonViews =
new ObservableCollection<PersonView>();
PersonView gridView = new PersonView();
gridView.Location =
"Chicago";
gridView.Name =
"Fred";
PersonOccupation tc = new PersonOccupation();
tc.ID = 1;
tc.Occupation =
"Programmer";
gridView.Occupation =
new ObservableCollection<PersonOccupation>();
gridView.Occupation.Add(tc);
tc =
new PersonOccupation();
tc.ID = 2;
tc.Occupation =
"Sales";
gridView.Occupation.Add(tc);
tc =
new PersonOccupation();
tc.ID = 3;
tc.Occupation =
"Tech";
gridView.Occupation.Add(tc);
PersonViews.Add(gridView);
gridView =
new PersonView();
gridView.Location =
"NY";
gridView.Name =
"Joe";
tc =
new PersonOccupation();
tc.ID = 1;
tc.Occupation =
"Cook";
gridView.Occupation =
new ObservableCollection<PersonOccupation>();
gridView.Occupation.Add(tc);
tc =
new PersonOccupation();
tc.ID = 2;
tc.Occupation =
"Chef";
gridView.Occupation.Add(tc);
tc =
new PersonOccupation();
tc.ID = 3;
tc.Occupation =
"Tech";
gridView.Occupation.Add(tc);
PersonViews.Add(gridView);
gridView =
new PersonView();
gridView.Location =
"LA";
gridView.Name =
"Sam";
tc =
new PersonOccupation();
tc.ID = 1;
tc.Occupation =
"Tech";
gridView.Occupation =
new ObservableCollection<PersonOccupation>();
gridView.Occupation.Add(tc);
tc =
new PersonOccupation();
tc.ID = 2;
tc.Occupation =
"Student";
gridView.Occupation.Add(tc);
tc =
new PersonOccupation();
tc.ID = 3;
tc.Occupation =
"Writer";
gridView.Occupation.Add(tc);
PersonViews.Add(gridView);
}
public ObservableCollection<PersonView> PersonViews
{
get { return _personViews; }
set
{
if (_personViews != value)
{
_personViews =
value;
RaisePropertyChanged(
"GridViews");
}
}
}
public event PropertyChangedEventHandler PropertyChanged;
private void RaisePropertyChanged(string propertyName)
{
// take a copy to prevent thread issues
PropertyChangedEventHandler handler = PropertyChanged;
if (handler != null)
{
handler(
this, new PropertyChangedEventArgs(propertyName));
}
}
}
public class PersonView : INotifyPropertyChanged
{
private ObservableCollection<PersonOccupation> _occupation;
public string Name
{
get;
set;
}
public string Location
{
get;
set;
}
public ObservableCollection<PersonOccupation> Occupation
{
get { return _occupation; }
set
{
if (_occupation != value)
{
_occupation =
value;
RaisePropertyChanged(
"Person");
}
}
}
public event PropertyChangedEventHandler PropertyChanged;
private void RaisePropertyChanged(string propertyName)
{
// take a copy to prevent thread issues
PropertyChangedEventHandler handler = PropertyChanged;
if (handler != null)
{
handler(
this, new PropertyChangedEventArgs(propertyName));
}
}
}
public class PersonOccupation : INotifyPropertyChanged
{
private string _occupation;
private int _ID;
public string Occupation
{
get { return _occupation; }
set
{
if (_occupation != value)
{
_occupation =
value;
RaisePropertyChanged(
"Occupation");
}
}
}
public int ID
{
get { return _ID; }
set
{
if (_ID != value)
{
_ID =
value;
RaisePropertyChanged(
"ID");
}
}
}
public event PropertyChangedEventHandler PropertyChanged;
private void RaisePropertyChanged(string propertyName)
{
// take a copy to prevent thread issues
PropertyChangedEventHandler handler = PropertyChanged;
if (handler != null)
{
handler(
this, new PropertyChangedEventArgs(propertyName));
}
}
}
}