I have a WPF XamMultiColumnComboEditor whose ItemsSource is bound to a view model property that returns List(Of ELReason). The object ELReason has multiple properties, and the dropdown elements in the combo display multiple columns.
The individual ELReason objects in the list have multiple properties, one of which is the DisplayMemberPath (Name) and one of which I would like to be the SelectedValuePath (Id).
Further, I would like two-way binding between this SelectedValue property (Id) and a property in my viewmodel object (ReasonId).
Since the XamMultiColumnComboEditor does not have a SelectedValuePath property, I followed an example on the forums to subclass XamMultiColumnComboEditor as a class called XamMultiColumnComboEditorEx. This subclass implements the SelectedValuePath property.
I also created a binding on the SelectedValue property to my viewmodel property (ReasonId). But I do not get any inital value selected, nor does the property set method get called when I change the selection in the combo.
I have a simple project attached that demonstrates the issue. I am using NetAdvantage 2012.1 for WPF.
Please let me know if I am doing something wrong or if you have any thoughts about how to do this properly.
Thanks
Hello,
Thank you for your post. I have been looking into you application and the reason for the binding to not update the ViewModel is that the default mode of the Binding is OneWay and when you select an item of the ComboEditor, the SelectedValue property is not updating the view model. What I can suggest is setting the Mode property of the Binding for the SelectedValueProperty to TwoWay, in the method that you are creating the editor.
Regarding the second issue, the reason for the editor to not update the SelectedItem property when you set the SelectedValue, is that the definition of the SelectedValuePrperty does not contains a callback, where based on the e.NewValue the SelectedItem property should be set, so when you set a value to the SelectedValue property, the item corresponding to that value to become selected. I have modified the sample application that you have attached to show how you can implement those changes.
Please let me know if you need any further assistance on the matter.
Sincerely,
Krasimir
Developer Support Engineer
Infragistics
www.infragistics.com/support
Hello Krasimir,
I have implemented your suggestion and can report that it works perfectly.
Thanks for the assistance,
David Drucker