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
2395
XamComboEditor.DisplayMemberPath not working properly?
posted

Hi,

I have set .DisplayMemberPath="FullName" on one of my XamComboEditor control.

If I select any item of the drop down list then this gets properly displayed (using the "FullName") property. However, if I assign an object to the .Value property, then the "FullName" property is not accessed but the object is rendered using the .ToString() method.

Is that expected?

 

 

  • 5124
    Suggested Answer
    posted

    Hello,

    I believe that you need to set the editor's ValuePath property to be the name of the property that uniquely identifies the Item.  Then, when you set the editor's  Value property, instead of setting it to an Item object, you set it to that property which you had identified as the ValuePath property. 

    Please see the attached sample that demonstrates what I tried to describe.  A XamComboEditor is bound (in the code-behind) to an ObservableCollection of Category objects.   The ValuePath is set to the CategoryID.  The DisplayMemberPath is set to CategoryName.  When setting the Value, you can set it to Category.CategoryID, and not simply to an object of type Category.

    I hope this helps.

    Thanks,

    XCE_ValuePathDemo_WPF4.zip