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
55
XamComboEditor does not set value of bound property
posted

Hi,

I'm working with an XamDataGrid, dynamically adding a bunch of UnboundField's based on user selection. The reason for 'UnboundField's is that I want to set the BindingPath property, to allow binding to properties that don't exist directly on the bound object (e.g. 'Property1.SomeProperty'). This has all been working beautifully and I am able to both view and edit the values of these properties via the grid.

However, I am now trying to use an XamComboEditor as the editor type for some fields. So I am setting the FieldSettings EditorType property to typeof(XamComboEditor) and I am building a ComboBoxItemsProvider and setting it as the ItemsProvider via a Style assigned to the EditorStyle property. The ComboBoxItemsProvider ItemsSource property is set to a BindingList containing a collection of the available objects for the bound property. The type of the objects in the BindingList is one of my own, but it matches the type of the property that the UnboundField is bound to. I am setting the DisplayMemberPath, but not the ValuePath as I want the Value to be equal to the selected item.

This works for displaying the correct value of the property on each row, however when I pick a different item from the combo box, nothing happens. The property setter is never called.

Is this something to do with the fact I'm using 'UnboundField's? I find that name very misleading as I am actually binding these fields directly to my data and they do allow editing in other circumstances.

Hope you can help.

Parents
No Data
Reply
  • 55
    Verified Answer
    posted

    After a lot of trial and error I have managed to solve the problem myself. The issue is that the UnboundField DataType property does not auto-resolve based on the PropertyPath. When I manually set the DataType, the TwoWay binding all works perfectly.

    I'm not sure if such a thing exists already, but I've written a helper extension method for PropertyPath that resolves the Type of the referenced property. I've attached it to this post. Note that this does not currently support PropertyPaths that include indexes, but it could be improved to do so.

    - Stuart

Children
No Data