Hi
I have XamDataGrid fields initialized in code-behind in the FieldLayoutInitializing event handler. In the data grid I have a bound field called "Level" which is a ComboBox. The items of ComboBox can change dynamicaly in run-time according to user's choise of radio-button (outside of the data grid).
This is how I populate the ComboBox of the "Level" field in FieldLayoutInitializing event handler:
();
cbip.ItemsSource = vm.GetEnumerationForField(fmd.Name);
));
s.Setters.Add(
.ItemsProviderProperty,
cbip));
field.Settings.EditorType =
);
Where :
vm - is a ViewModel class
GetEnumerationForField(fieldName) - returns an ObservableCollection<string> of items to populate the combobox.
Now, how can I change the items of the combobox at run-time?
Thank you
Hello,
There are couple of ways.
1. You can create a new style and a new provider with the new items and assign that style to that field.
2. You can define the provider as a StaticResource so that you can easily get an instance of it later and add the new items
3. You can store the collection that you set to the provider's ItemsSource property (the one from the GetEnumerationForField method) and add items directly in it