A combobox in my gridview needs to have different ItemsSource depending on the value of another column.
I've tried to solve this by listening on the gridview's PreparingCellForEdit event:
...and this kind-of works. The combobox displays its SelectedValue once it is selected and the dropdown shows the correct list of values.
However, when the combobox is not in edit-mode, it looks empty. I'd like to bind a TextBlock with the SelectedValue for display, but don't know how to accomplish that.
Any thoughts would be appreciated.
I've tried to solve this by listening on the gridview's PreparingCellForEdit event:
private void RadGridView_PreparingCellForEdit(object sender, GridViewPreparingCellForEditEventArgs e) { switch (e.column.Name) { case "MyDynamicColumn": var combobox = e.EditingElement as RadComboBox; combobox.ItemsSource = List<string> { "1", "2", "3" }; //TODO: Replace with some dynamic business logic here combobox.SetBinding(RadComboBox.SelectedValueProperty, "MyComboValue"); break; } } } ...and this kind-of works. The combobox displays its SelectedValue once it is selected and the dropdown shows the correct list of values.
However, when the combobox is not in edit-mode, it looks empty. I'd like to bind a TextBlock with the SelectedValue for display, but don't know how to accomplish that.
Any thoughts would be appreciated.
