I have a XamComboEditor in my datagrid. I know how to add items to this in XAML (using ItemProvider and setting it to the EditorStyle) but what I really need is to be able to programmatically set the items of the combobox.. any ideas on how to do this?
Not exactly what I was thinking about priviously, but this will solve my problem :)
Thanks!
Hello,
A quick way to do this is by create a new ComboBoxItemsProvider and then set it to the XamComboEditor's ItemsProvider Property like this:
ComboBoxItemsProvider comboBoxItems = new ComboBoxItemsProvider(); ObservableCollection<string> itemsCollection = new ObservableCollection<string>(); itemsCollection .Add("1"); itemsCollection .Add("2"); itemsCollection .Add("3"); comboBoxItems.ItemsSource = itemsCollection ; CellValuePresenter cvp = CellValuePresenter.FromRecordAndField(xamDG.Records[0] as DataRecord,xamDG.FieldLayouts[0].Fields[1]); XamComboEditor xce = cvp.Editor as XamComboEditor; xce.ItemsProvider = comboBoxItems;
xce.SelectedIndex = 0;
Hope this helps.