wpf 中Listbox獲取選中的值


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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM