获取列表框的Windows Phone 7的价值选择
问题描述:
我想获得一个列表框的选定项的文本。
但我要System.Windows.Controls.ListBoxItem的结果。
I am trying to get the text of the selected item of a listbox. But i should a result of "System.Windows.Controls.ListBoxItem"
我的代码:
listBox.SelectedItem.ToString();
My code: listBox.SelectedItem.ToString();
我应该如何改变我的代码?
How should i change my code?
答
试试这个
if(null != listBox.SelectedItem)
{
string text = (listBox.SelectedItem as ListBoxItem).Content.ToString();
}