Hi there,
I’m having trouble to use a XamComboEditor in a XamDataGrid UnboundField.
I have a ViewModel which saves my possible ComboBox-selection in a unit-ObservableCollection, this selectable object has a Name, a UnitSymbol and a UnitId property.
On the other hand my XamDataGrid gets a collection of Parameters, where every object has an own instance of a unit. So for this reason I can’t use SelectedItem to preselect its own unit from my unit-Collection, because the object in the collection and in the Parameter is different, even with the same metadata. (btw. if every parameter-object gets his unit from my unit-collection everything is just fine, when I use SelectedItem)
So my problem is that I want to show my Parameter-unit with its UnitSymbol but I have to select it by its UnitId, to match it with my unit-collection.
If I try to use the ValuePath-Property I only get the object-name displayed.
Also every Parameter has some Child-Parameter with the same type.
BR
Andreas
Hello Andreas,
Thank you for your feedback. I believe that other community members may benefit from this as well.
Thanks again.
Hello Stefan,
Thanks for your help. I only though there would be a way to select the DataItem by some sort of ID and I don’t need necessary an instance from my collection. But if you say my DataItem must be an instance from the collection I can live with that, in my final application I did this already as some kind of ‘workaround’.
BR and have a nice weekend
By default the DataType Property of the UnboundField is String, so you have to set it to "ParameterUnit". Also the DataItem's Unit Property should be an instance from the Units collection so it could be selected correctly. I made this changes to the sample application, so now it works as you want. Please let me know if this helps you or you have further questions on this matter. Looking forward for your reply.
Hi Stefan,
Thank you for your response. It’s correct if I remove the ValuePath, the unit will be shown. But in this case the Value from my DataItem is not selected, only the first Item from my ItemSource.
In my case this means, if I remove the ValuePath the unit ‘m’ will be selected and not the unit ‘g’ from my Parameter.
Thank you for your post. I have been looking into it and the sample you have uploaded and I can suggest you remove the ValuePath of the XamComboEditor, because the value of the UnbundField is ParameterUnit type and if you set the value path, it means that you are trying to set a String value to this type and exceptions are thrown in the Output. Please let me know if this helps you or you have further questions on this matter.
Looking forward for your reply.