检索组合框winrt的显示值

时间:2013-07-13 09:35:25

标签: c# windows-runtime

我设置了DisplayMemberPath以及comboBox的{​​{1}},现在我正在尝试检索显示的ItemsSource,但没有selectedText 1}}属性。我试过了

selectedText

但我得到一个奇怪的价值。如何检索comboBox的显示值

1 个答案:

答案 0 :(得分:1)

对于comboBox1,在C#winforms中,您可以使用comboBox1.SelectedItem.ToString()获取所选值。在WPF中(显然你想要的),你可以直接从Content属性获取这些信息;您可以通过执行以下操作来访问它:

ComboBoxItem curItem = (ComboBoxItem)comboBox1.SelectedItem;
string selectedValue = curItem.Content.ToString();
相关问题