Skip to content
This repository was archived by the owner on Feb 25, 2026. It is now read-only.
This repository was archived by the owner on Feb 25, 2026. It is now read-only.

Add click event for row- Datagrid #2388

Closed

Description

@Kath118

I'm submitting a...

New Feature

Please add a click event for row in datagrid.
The selection changed event does not work when is necessary to open a new page.
Because to select the same row is necessary select another row and then re-select the previous row.

Activity

  1. kbrons commented on Aug 10, 2018

    @kbrons
    Contributor

    Hi @Kath118, can you create a uservoice request for the issue and add it to your comment?

    Thanks!

  2. added
    feature request 📬
    DataGrid 🔠
    on Aug 10, 2018
  3. Kath118 commented on Aug 10, 2018

    @Kath118
    Author
  4. robloo commented on Oct 30, 2018

    @robloo
    Contributor

    A RowPressed and ColumnHeaderPressed event would be very useful for the DataGrid. I need both of these and it's requiring some ugly hacks to get this functionality.

    RowPressed should allow detection of both Left and Right mouse button for context menus. DoublePressed would be a bonus.

    ColumnHeaderPressed should also allow Left and Right press for context menus. Not sure how to prioritize Left press over Sorting event.

  5. skendrot commented on Oct 30, 2018

    @skendrot
    Contributor

    How would this be different from the SelectionChanged event?

  6. robloo commented on Nov 1, 2018

    @robloo
    Contributor

    There are many standard use cases that SelectionChanged doesn't support. For example: right click of a row in the table to show a context menu. Also double clicking a row to open it up in an editor. SelectionChanged is conceptually different and has different use cases than a Pressed/Click event. I think ListViewBase supports ItemClick for reference.

    Right now I have to implement something like what is below. Usable but it should be out-of-the-box functionality of the DataGrid in my opinion.

            private void DataGrid_PointerPressed(object sender, PointerRoutedEventArgs e)
            {
                PointerPoint point = e.GetCurrentPoint(sender as UIElement);
    
                // Determine the pressed row by navigating the VisualTree (a helper method does this)
                DataGridRow pressedRow = UIUtilities.FindParent<DataGridRow>(e.OriginalSource as DependencyObject);
    
                if (point.Properties.IsRightButtonPressed)
                {
                   // Context menu
                }
                else
                {
                   // Do something like track double press and then open a row in an editor
                }
                
                return;
            }
    

    There is then a lot of additional code to track double press and get the index of the DataGridRow and correlate it back into the ItemsSource element so it can be selected, etc.

    All of this said, ColumnHeaderPressed is even more useful to implement filtering Flyouts and other controls to edit the columns. I still haven't found a good way to do this one.

  7. robloo commented on Nov 18, 2018

    @robloo
    Contributor

    Duplicate of #2249

  8. lukeblevins commented on Nov 18, 2018

    @lukeblevins
    Contributor

    Glad to see that some attention is being paid to this. ;)
    In the application I'm building, users currently have to manually select the row before right-clicking in order to display the row-appropriate context menu. Otherwise, it just displays the column header context menu. I think it would be more user-friendly to have a RowRightTapped which autoselects the nearest row and fires (all on rightclick).

  9. windowstoolkitbot commented on Jan 17, 2019

    @windowstoolkitbot

    This issue seems inactive. It will automatically be closed in 14 days if there is no activity.

  10. windowstoolkitbot commented on Jan 25, 2019

    @windowstoolkitbot

    This issue seems inactive. It will automatically be closed in 14 days if there is no activity.

  11. windowstoolkitbot commented on Feb 2, 2019

    @windowstoolkitbot

    This issue seems inactive. It will automatically be closed in 14 days if there is no activity.

  12. windowstoolkitbot commented on Feb 10, 2019

    @windowstoolkitbot

    Issue is inactive. It was automatically closed.

  13. robloo commented on Feb 10, 2019

    @robloo
    Contributor

    @harinikmsft , @nmetulev Why are issues like this being automatically closed? I understand wanting to avoid permanently open items but these types of things must not just be shutdown automatically. Please change the system from auto-closing these and please reopen this issue.

  14. ghost locked as resolved and limited conversation to collaborators on Nov 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

DataGrid 🔠controls 🎛️feature request 📬

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions