布局代碼: <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值。