1

I can see based on this question: https://stackoverflow.com/a/3120866/181771 that it's possible to add a double-click event to a DataGrid row, e.g.:

<DataGrid ... >
    <DataGrid.ItemContainerStyle>
        <Style TargetType="DataGridRow">
            <EventSetter Event="MouseDoubleClick" Handler="Row_DoubleClick"/>
        </Style>
    </DataGrid.ItemContainerStyle>
    ...
</DataGrid>

Is it possible for me to do this in C#, depending on certain conditions? If so, how?

Community
  • 1
  • 1
DaveDev
  • 41,155
  • 72
  • 223
  • 385
  • Check out UIElement.AddHadnler(). Add the handler to the entire grid and then check e.OriginalSource in the event handler. – user3455395 Mar 28 '14 at 12:50

1 Answers1

1

Try this:

myRow.MouseDoubleClick += new RoutedEventHandler(Row_DoubleClick);
Racil Hilan
  • 24,690
  • 13
  • 50
  • 55
  • Not exactly sure but adding it at a row level could be challenging (int terms of both perf and coding effort) as it'll require post processing for each Db change - I'd suggest to handle it at a DataGrid level and then filter it by OriginalSource type, that's what routed events are designed for aren't they? – user3455395 Mar 28 '14 at 13:09