【发布时间】:2014-07-04 22:51:36
【问题描述】:
我有以下列表框:
<ListBox ItemsSource="{Binding CityList}">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel>
<TextBlock x:name="Name" Text="{Binding Name }" />
<TextBlock x:name="Country" Text="{Binding Country}" />
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
下面的文章很好地解释了如何实现 SelectionChanged :
<phone:LongListSelector x:Name="Results" Margin="0,0,-12,0" ItemsSource="{Binding Events}" SelectedItem="{Binding Event}">
<phone:LongListSelector.ItemTemplate>
<DataTemplate>
<StackPanel Margin="0,0,0,17">
<TextBlock Text="{Binding benchmark.name}" TextWrapping="Wrap" Style="{StaticResource PhoneTextExtraLargeStyle}"/>
<TextBlock Text="{Binding summary}" TextWrapping="Wrap" Style="{StaticResource PhoneTextNormalStyle}"/>
</StackPanel>
</DataTemplate>
</phone:LongListSelector.ItemTemplate>
<i:Interaction.Triggers>
<i:EventTrigger EventName="Tap">
<command:EventToCommand Command="{Binding WodSelectedCommand, Mode=OneWay}" CommandParameter="{Binding Path=SelectedItem, ElementName=Results}" PassEventArgsToCommand="False"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</phone:LongListSelector>
但在本例中,Selection Changed 对于我的示例中的每个文本块都是相同的,我希望我的两个文本块有两个不同的命令。
我该怎么做?
【问题讨论】:
标签: c# .net mvvm listbox mvvm-light