I have a WPF application that contains a datagrid. It is bound to my List object \"Orders\" shown below.
public class OrderBlock
{
public Settings setting;
I'v used the MouseDoubleClick:
private void DataGrid_MouseDoubleClick(object sender, MouseButtonEventArgs eventArgs)
{
if (sender == null) return;
if (eventArgs.ButtonState != MouseButtonState.Pressed) return; //only react on pressed
var dataGrid = sender as DataGrid;
if (dataGrid == null || dataGrid.SelectedItems == null) return;
if (dataGrid.SelectedItems.Count == 1)
{
var simplePension = dataGrid.SelectedItem as ISimplePension;
if (simplePension != null)
{
DataFetcherHolder.DataFetcher.SelectPension(simplePension);
Execute(EditSelectedPensionFunction);
}
}
}
When you double-click a data grid, the row is also selected, so I simply find the selected item and use it.