wpf - How do I bind to different property on ComboBox SelectedItem? -


i have combobox in wpf this:

<combobox text="select language..." iseditable="true" isreadonly="true"           itemssource="{binding xpath=item/@name, source={staticresource items}}"           selecteditem="{binding path=test, mode=onewaytosource}"/> 

where items is:

<xmldataprovider x:key="items" source="/itemlist.xml" xpath="/itemlist"/> 

test property of type object on viewmodel set datacontext of window.

everything works fine, , test property receives xmlnode object, makes sense.

however, receive different attribute xml example xpath=item/@value

how do that?

use displaymemberpath , selectedvaluepath:

<combobox text="select language..." iseditable="true" isreadonly="true"   itemssource="{binding xpath=item, source={staticresource items}}"   displaymemberpath="@name"   selectedvaluepath="@id"   selectedvalue="{binding path=test, mode=onewaytosource}"/> 

the selected item item element, display name attribute, , bind id attribute test.


Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -