我有一個綁定到一個ObservableCollection一個ListBox:更改標籤內容基於列表框選擇
<ListBox Name="ListBoxItemsList">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid Margin="0" FlowDirection="RightToLeft">
<Button Content="Add me!" Click="AddItem" />
<TextBlock Text="{Binding Path=name}" />
<TextBlock Text="{Binding Path=description}" />
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
的的ObservableCollection對象有幾個屬性,包括uniqueID
,name
,description
,colour
,flavour
。根據列表框中的選定項目,我想用選定項目的屬性填充一些標籤。此外,每個項目的按鈕應該執行一個獨特的操作(即添加一個相關項目到一個數組),但我不知道如何發送一個唯一的參數到AddItem()方法。我認爲這將是一個常見用例,但我無法通過Google搜索找到任何東西。
謝謝。
'我想要一些標籤的細節來顯示所選項目的屬性'...'一些標籤的細節顯示'?? – 2012-03-13 14:32:36
謝謝,我重寫了這句話。 – dotancohen 2012-03-13 18:14:28
你是usijng mvvm嗎? – 2012-03-13 18:27:46