WPF implement SelectedCommand in MVVM via Interaction.Triggers
1 xmlns:i="http://schemas.microsoft.com/xaml/behaviors" 2 3 4 <ListBox x:Name="peopleLbx" ItemsSource="{Binding PersonList}"> 5 <i:Interaction.Triggers> 6 <i:EventTrigger EventName="SelectionChanged"> 7 <prism:InvokeCommandAction Command="{Binding PersonSelectedCommand}" CommandParameter="{Binding SelectedItem,ElementName=peopleLbx}"/> 8 </i:EventTrigger> 9 </i:Interaction.Triggers> 10 </ListBox> 11 12 PersonSelectedCommand = new DelegateCommand<Person>(PersonSelectedExecuted); 13 14 private void PersonSelectedExecuted(Person obj) 15 { 16 // Todo 17 }