, MVVM
, , Command Property Button,
, , ""
XMAL
<ListBox Name="MyListBox" ItemsSource="{Binding ListItems}" Height="150" Width="150" Margin="281,32,-31,118">
<Local:Interaction.Triggers>
<Local:EventTrigger EventName="SelectionChanged">
<Local:InvokeCommandAction Command="{Binding MyCommand}" CommandParameter="{Binding ElementName=MyListBox,Path=SelectedItem}"/>
</Local:EventTrigger>
</Local:Interaction.Triggers>
</ListBox>
dll Syatem.Windows.Interactivity
xaml,
xmlns:Local="clr-namespace:System.Windows.Interactivityassembly=System.Windows.Interactivity"
ViewModel Con
public ViewModel123()
{
MyCommand = new RelayCommand<string>(TestMethod);
}
TestMethod,
private void TestMethod(string parameter)
{
MessageBox.Show(parameter);
}
, .