I have a DataGrid, whose ItemsSource binding to an ObservableCollection. And:
- The 1st column binding to Name property;
- The 2nd column binding to Age property;
Now I want to add the 3rd column, using DataGridComboBoxColumn control. And it's content shall be all the Names of column 1. When adding or removing a row, the content of DataGridComboBoxColumn shall add or remove a Name correspondingly.
The only way I thought out is very silly: Just create a new ObservableCollection called NameList. And everytime adding or removing a row to DataGrid, add or remove a name to the NameList at the same time.
Is there any better way?