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

windows - Why does Vista not allow creation of shortcuts to "Programs" on a NonAdmin account? Not supposed to install apps from NonAdmin account? -

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

unit testing - How to mock PreferenceManager in Android? -