Reputation: 1456
I have a DataGrid in WPF that contains a list of names and email addresses, and an event handler that performs an action when a row is double-clicked:
<DataGrid x:Name="DataGrid_Emails" ItemsSource="{Binding AddressBook}">
<DataGrid.RowStyle>
<Style TargetType="{x:Type DataGridRow}">
<EventSetter Event="MouseDoubleClick" Handler="DataGrid_Emails_RowDoubleClick"/>
</Style>
</DataGrid.RowStyle>
<DataGrid.Columns>
<DataGridTextColumn Header="Name" Binding="{Binding Path=Name}"></DataGridTextColumn>
<DataGridTextColumn Header="Email" Binding="{Binding Path=Email}"></DataGridTextColumn>
</DataGrid.Columns>
</DataGrid>
I'd like to be able to extend this functionality to work on multiple rows if multiple rows are selected. Is it possible for me to simply add somethins to my EventSetter to cover this scenario?
Upvotes: 1
Views: 2308
Reputation: 12295
I dont think you can add anything to this because you can doubleclick only one row at a time. But you can get the Selected Rows in your handler and apply your action to them. For that In your handler you can use SelectedItems property of DataGrid.
Upvotes: 1