簡體   English   中英

迭代列表框Silverlight的內容

[英]Iterating content of listbox silverlight

我有一個列表框

 <ListBox Width="400" Height="150" x:Name="QuestionsBox" Margin="0,0,0,40">
            <ListBoxItem Name="Item1" Content="Hello"></ListBoxItem>
            <ListBoxItem Name="Item2" Content="Hello"></ListBoxItem>

</ListBox>

我想在選擇該項目時在列表框中顯示該項目的內容。 就像,如果用戶選擇Item1,那么我應該能夠獲得內容-您好

我嘗試使用SelectedItem屬性[QuestionsBox.SelectedItem]但在運行時似乎沒有得到內容的值。

請幫忙

<TextBlock Text="{Binding SelectedItem.Content, ElementName=QuestionsBox}" />

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM