Binding Combobox SelectedItem by a field's value

Posted by Navid Farhadi on Stack Overflow See other posts from Stack Overflow or by Navid Farhadi
Published on 2010-12-20T14:27:36Z Indexed on 2010/12/21 12:54 UTC
Read the original article Hit count: 343

Filed under:
|
|
|
|

Combobox bind to a set of Provinces, Village object has ProvinceID field and i want to bind SelectedItem of Combobox to a Province with Village's ProvinceID.

My code is:

<ComboBox ItemsSource="{Binding ProvincesList}" 
          DisplayMemberPath="ProvinceName" 
          SelectedValuePath="ProvinceID" 
          SelectedValue="{Binding Village.ProvinceID}" />

But SelectedItem is anything.

© Stack Overflow or respective owner

Related posts about c#

Related posts about Silverlight