布局代码: <ListBox Name="listBox1" Width="120" Height="52" SelectionChanged="listBox1_SelectionChanged" >
<ListBoxItem Tag="Red1">Red</ListBoxItem>
<ListBoxItem Tag="Yellow1">Yellow</ListBoxItem>
<ListBoxItem>Blue</ListBoxItem>
</ListBox>
后台代码:
((ListBoxItem)listBox1.SelectedItem).Content;可以获取里面的内容:Red,Yellow,Blue。
((ListBoxItem)listBox1.SelectedItem).Tag,可以获取Tag值。
wpf 中Listbox获取选中的值
猜你喜欢
转载自www.cnblogs.com/fishyues/p/10178835.html
今日推荐
周排行