Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8721675
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:15:33+00:00 2026-06-13T07:15:33+00:00

I added a datagrid in a wpf application. <DataGrid ItemsSource={Binding Projects} SelectedItem={Binding SelectedProject} MouseDoubleClick=DataGrid_MouseDoubleClick

  • 0

I added a datagrid in a wpf application.

<DataGrid ItemsSource="{Binding Projects}" SelectedItem="{Binding SelectedProject}" MouseDoubleClick="DataGrid_MouseDoubleClick" />

and here is my code behind

private void DataGrid_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
    if selected row is header
        then do this
    else
        do this
}

Now question is how I came to know which one is double clicked. It is header or a row. How I can find it out.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T07:15:34+00:00Added an answer on June 13, 2026 at 7:15 am

    Instead of adding double click event in DataGrid, add sperate event for DataGridRow and DataGridColumnHeader.
    Updated XAML:

    <DataGrid ItemsSource="{Binding Projects}" SelectedItem="{Binding SelectedProject}" MouseDoubleClick="DataGrid_MouseDoubleClick"> 
        <DataGrid.Resources>
            <Style TargetType="DataGridRow">
                <EventSetter Event="MouseDoubleClick" Handler="DataGridRow_MouseDoubleClick" />
            </Style>
        </DataGrid.Resources>
        <DataGrid.Resources>
            <Style TargetType="DataGridColumnHeader">
                <EventSetter Event="MouseDoubleClick" Handler="DataGridColumnHeader_MouseDoubleClick" />
            </Style>
        </DataGrid.Resources>
    </DataGrid>
    

    And here is code behind.

    private void DataGridRow_MouseDoubleClick(object sender, System.Windows.RoutedEventArgs e)
    {
        // This is when a row is double clicked.
    }
    
    private void DataGridColumnHeader_MouseDoubleClick(object sender, System.Windows.RoutedEventArgs e)
    {
        // This is when header is double clicked.
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I added a record in a table of SQLServer with WPF-application and refresh DataGrid
I have a datagrid in my wpf application and I have a simple problem.
I have a WPF DataGrid that must have the row headers and columns added
I've got a strange problem here regarding sorting of a WPF DataGrid (System.Windows.Controls.DataGrid in
I have wpf datagrid, in one of columns, I checkboxes added in it, now
I have a wpf datagrid. I have added styling to show a mouseover color
I have WPF form with DataGrid. New columns can be added to the datagrid
I am working with a WPF application, and I am working on a DataGrid
We are using XamDataGrid in our WPF application. It works well, we added support
I have a Datagrid, that shows Columns, that are added by setting the ItemsSource-Property

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.