我有一个绑定到一个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