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?

1
  • Check out UIElement.AddHadnler(). Add the handler to the entire grid and then check e.OriginalSource in the event handler. Commented Mar 28, 2014 at 12:50

1 Answer 1

2

Try this:

myRow.MouseDoubleClick += new RoutedEventHandler(Row_DoubleClick);
Sign up to request clarification or add additional context in comments.

1 Comment

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?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.