Difference between SelectedItem, SelectedValue and SelectedValuePath

后端 未结 5 813
轻奢々
轻奢々 2020-11-22 01:20

What is the difference betweeen the following:

  • SelectedItem
  • SelectedValue
  • SelectedValuePath

All these dependency properties ar

5条回答
  •  时光说笑
    2020-11-22 01:28

    inspired by this question I have written a blog along with the code snippet here. Below are some of the excerpts from the blog

    SelectedItem – Selected Item helps to bind the actual value from the DataSource which will be displayed. This is of type object and we can bind any type derived from object type with this property. Since we will be using the MVVM binding for our combo boxes in that case this is the property which we can use to notify VM that item has been selected.

    SelectedValue and SelectedValuePath – These are the two most confusing and misinterpreted properties for combobox. But these properties come to rescue when we want to bind our combobox with the value from already created object. Please check my last scenario in the following list to get a brief idea about the properties.

提交回复
热议问题