Silverlight - how do I get the text of the selected item in a combobox

后端 未结 7 1219
臣服心动
臣服心动 2021-01-18 13:14

Easy one for you all...

I\'m new to Silverlight and really missing stuff like DataTables and things. What I\'m also currently struggling with is how to get the text

7条回答
  •  执笔经年
    2021-01-18 13:29

    For a complex object, use reflection with the DisplayMemberPath property:

    var itemType = cbx.SelectedItem.GetType();
    var pi = itemType.GetProperty(cbx.DisplayMemberPath);
    var stringValue = pi.GetValue(cbx.SelectedItem, null).ToString();
    

提交回复
热议问题