Difference between SelectedItem, SelectedValue and SelectedValuePath

后端 未结 5 802
轻奢々
轻奢々 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:46

    SelectedItem is an object. SelectedValue and SelectedValuePath are strings.

    for example using the ListBox:

    if you say give me listbox1.SelectedValue it will return the text of the currently selected item.

    string value = listbox1.SelectedValue;
    

    if you say give me listbox1.SelectedItem it will give you the entire object.

    ListItem item = listbox1.SelectedItem;
    string value = item.value;
    

提交回复
热议问题