Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
615
DataType Gets Lost in CellValuePresenter with Combobox and DataBinding
posted

Hello,

I am having trouble with DataBinding and the CellValuePresenter.

In a XamDataGrid I am setting the template of the CellValuePresenter to a combobox. The value list of the combobox is bound to a property of the underlying row object (different rows may have different value lists). The row object has a list of values for each column. Each value (column) is bound to the CellValuePresenter. In the attached example enumeration are used for the value list and the value is one of the enums. The issue is that if one changes the selection of the combobox, the value that is written back to the data object, has not the enumeraton type any more. It's a string!

How can I keep the type information?

Thanks in advance, Florian

WpfApplication2.zip
  • 138253
    Offline posted

    Hello Florian,

    It has been a while since you have made your post, in case you still need support I will be glad to assist you further. I suppose the other community members can benefit from this answer as well. I have been looking through your post and the sample project you provided and I edited, so it now works as you want. Basically I add a custom converter for the ComboBox and implement its ConvertBack method, so that now it returns Visibility or BindingMode type, because the Editors used in the XamDataGrid converts the data into string, integer, Decimal or double in order to work with it.

    Feel free to write me if you have further questions.