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

后端 未结 7 1240
臣服心动
臣服心动 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:36

    If you have a simple combobox for an array of strings, you can get the selected string using

    (string)e.AddedItems[0];
    

    Suppose I have a product list combo and I want to know the selected product name. So in the SelectionChanged Event I write the following code:

    private void productCombo_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
            {
                string product_type=(string)e.AddedItems[0];
            }
    

提交回复
热议问题