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

  • Home
  • SEARCH
  • 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 4574568
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T19:56:28+00:00 2026-05-21T19:56:28+00:00

I have developed a WPF UserControl that is intended to be used as a

  • 0

I have developed a WPF UserControl that is intended to be used as a pick list as follows:

  • A DataGrid bound to a CollectionView of entities (e.g. of Employees)
  • A TextBox above the DataGrid that can be used to filter items displayed in the DataGrid.

I want to expose a Command that will be executed when the user double-clicks on a row in the DataGrid. The container can then react to this by doing something with the SelectedItem in the DataGrid.

So far I’ve tried to handle the double-click as follows:

<DataGrid IsReadOnly="True">
    <DataGrid.InputBindings>
        <MouseBinding MouseAction="LeftDoubleClick" Command="... />
    </DataGrid.InputBindings>
...

However the double-click event still fires when the user clicks in the DataGrid header. I’d like to be able to limit it so that the Command is only executed when the double click is in the body of the DataGrid. Is there a declarative way to do this?

UPDATE

I’m just getting to grips with WPF and MVVM, and am really looking for guidance on how to implement low-level reusable components like this. Any general advice will also be gratefully received and upvoted. As it stands, I’m assuming I will want this UserControl to:

  • Expose a dependency property “SelectedItem” that is bound to the DataGrid’s SelectedItem

  • Expose a RoutedEvent “ItemDoubleClick” or similar that is fired when the user double-clicks on a row.

  • Implement ICommandSource and call CommandHelpers.ExecuteCommandSource(this) from the row double-click event handler.

  • 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-21T19:56:29+00:00Added an answer on May 21, 2026 at 7:56 pm

    If code behind is not a problem:

    <DataGrid.RowStyle>
        <Style TargetType="{x:Type DataGridRow}">
            <EventSetter Event="Loaded" Handler="Row_Loaded"/>
        </Style>
    </DataGrid.RowStyle>
    
    private void Row_Loaded(object sender, RoutedEventArgs e)
    {
        var row = sender as DataGridRow;
        row.InputBindings.Add(new MouseBinding(MyCommands.MyCommand,
                new MouseGesture() { MouseAction = MouseAction.LeftDoubleClick }));
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have developed a simple DB-editing app using Xceed's excellent DataGrid for WPF (UX
I have a WPF Keyboard Application, it is developed in such a way that
I have a desktop application developed in WPF that has several views displayed as
I have a WPF app that uses Flash10c.ocx developed on a 32 bit machine.
We are developing a customized installer using Wix and Wpf. We have developed some
I'm developing a graph control in WPF. I have previously developed it using GDI
I am an experienced WinForms/WPF/Silverlight developer and have an interview for a product that
I develop on VS2010 WPF on Window 7. I have a project that does
I have developed a web site that requires user registration and authentication for some
I have developed a Java server using Eclipse that accepts TCP socket connection from

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.