Hi, We want to be able to set the FieldSettings.EditorType of a field in the XamdataGrid to (Infragistics.Controls.Editors.XamComboEditor) instread of (Infragistics.Windows.Editors.XamComboEditor) because we want to take advantage of the multiselect feature. However, we are not being able to cast (Infragistics.Controls.Editors.XamComboEditor) to a ValueEditor.
field.settings.EditorType = typeof (Infragistics.Controls.Editors.XamComboEditor); throws an exception.
Is there another way to do this in code?
I am attaching a sample project which demonstrates the issue.
Hello Devaprem,
The Infragistics.Controls.Editors.XamComboEditor is our shared combo editor. Meaning that it works with both Silverlight and WPF. This editor does not derive from ValueEditor so it cannot be used as an EditorType for a Field. In order to use this editor you need to create a style on CellValuePresenter and then provide a template for the cell content. Inside this template you would use the shared editor and bind it to the appropriate data.
Based on the way your data is setup in the provided sample, I needed to write a Blend behavior that would take the Abilities from your PlayerData class and carry them over to the XamComboEditor. A direct binding cannot be done because firstly XamComboEditor does not support binding to a collection of basic strings (IEnumerable<string>). A complex type must be used. Also, the XamComboEditor does not have a bindable SelectedItems property. This is where the behavior comes in. Inside the behavior I provide my own SelectedItems property which is meant to be bound to the PlayerData.Abilities property. It then listens for selection change events on the editor and updates the PlayerData.Abilities appropriately. It also supports going the other way.
I have attached a modified version of your sample that contains the behavior code. Let me know if you have any questions.
Thanks for your sample. This works for me. However, this created a new problem. I was using the CellUpdated method of the xamDatagrid to to get notified when the value of the drop down was changed by the user (I then proceeded to persist the changes). However, since we are no longer using the field editor, the CellUpdated event does not get called when values are selected from the Abilities drop down. If there still a way to be notified in the CellUpdated event for this field? If not, which would be a comparable event on the control which I can use?
Also, is MultiSelect available on the a newer version of the Infragistics.Windows.Editors.XamComboEditor?