Silverlight ItemTemplate中带有按钮的列表框:在单击按钮时选择fire更改
我在ItemTemplate中有一个带有按钮的列表框。当我按下按钮时,一些命令被触发。我希望列表框在按钮单击事件发生时触发SelectionChanged事件。我应该如何激发ListBox SelectionChanged事件并传递适当的上下文Silverlight ItemTemplate中带有按钮的列表框:在单击按钮时选择fire更改,silverlight,Silverlight,我在ItemTemplate中有一个带有按钮的列表框。当我按下按钮时,一些命令被触发。我希望列表框在按钮单击事件发生时触发SelectionChanged事件。我应该如何激发ListBox SelectionChanged事件并传递适当的上下文 <ListBox ItemsSource="{Binding SomeSource}" > <ListBox.ItemTemplate> <DataTemplate> <Button Grid.Row="
<ListBox ItemsSource="{Binding SomeSource}" >
<ListBox.ItemTemplate>
<DataTemplate>
<Button Grid.Row="0" BorderThickness="0" Background="Transparent" HorizontalAlignment="Stretch">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<cmd:EventToCommand Command="{Binding SomeCommand}" CommandParameter="{Binding}" PassEventArgsToCommand="True" />
</i:EventTrigger>
</i:Interaction.Triggers>
<Button.Template>
<ControlTemplate>
<TextBlock Text="{Binding Title}" />
</ControlTemplate>
</Button.Template>
</Button>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
如果您可以在ViewModel中拥有SelectedItem属性,则可以将其双向绑定到列表框。SelectedItem,并在SomeCommand实现中设置ViewModel.SelectedItem,以便它反映到UI,并获得SelectionChanged调用