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 7070649
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:35:31+00:00 2026-05-28T05:35:31+00:00

I need my app to perform a certain action when DataGrid is double clicked.

  • 0

I need my app to perform a certain action when DataGrid is double clicked. The action should not be performed if a scrollbar is doubleclicked. So I try to see what is doubleclicked:

private void DataGrid_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            Point p = Mouse.GetPosition(this.DataGrid1);
            IInputElement ie = this.DataGrid1.InputHitTest(p);
        }

But when I doubleclick a scrollbar, then IInputElement appears to be all sort of stuff:
Microsoft.Windows.Themes.ScrollChrome or System.Windows.Shapes.Rectangle . So I am not sure if I clicked a scrollbar.

So how do I check if I really doubleclicked a scrollbar?

  • 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-05-28T05:35:32+00:00Added an answer on May 28, 2026 at 5:35 am

    There’s no need to use hit test here, just check if e.OriginalSource has a parent of ScrollBar type by traversing the visual tree. There’s one potential issues with this approach – your UI element has to be loaded, which is typically the case when dealing with mouse events anyway. Heres’ the code which checks if an UIElement has a parent of a specific type.

    public static T GetParentOfType<T>(DependencyObject current)
              where T : DependencyObject
            {
                for (DependencyObject parent = VisualTreeHelper.GetParent(current);
                    parent != null;
                    parent = VisualTreeHelper.GetParent(parent))
                {
                    T result = parent as T;
    
                    if (result != null)
                        return result;
                }
    
                return null;
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my web app I need to perform 3 types of searching on items
I need to perform video scaling in my C++ app. I know I can
I'm learning Backbone.js for a new app I'm building. I need to perform an
i need to perform an action when my application is installed. i've looked into
I need an app that sends an UDP packet to some network server and
I need to store app specific configuration in rails. But it has to be:
In my app i need to save changed values (old and new) when model
I need a simple app to edit database tables. Are there any code generators
In my app users need to be able to enter numeric values with decimal
In my app I need to draw a widget contents onto Bitmap. The code(pseudo)

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.