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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T09:47:32+00:00 2026-05-18T09:47:32+00:00

WPF, Shapes I have a custom Shape , and try to implement MouseClick and

  • 0

WPF, Shapes

I have a custom Shape, and try to implement MouseClick and MouseDoubleClick stuff on it.

By eg. I need to open a information window about MyShape OnClick and select it OnDoubleClick.

The stub is the following:

public class MyShape : Shape
{
    public Point Point1, Point2;

    public MyShape() : base() { }

    protected override Geometry DefiningGeometry
    {
        get { return new LineGeometry(Point1, Point2); }
    }

    protected override void OnMouseUp(MouseButtonEventArgs e)
    {
        base.OnMouseUp(e);
        if (e.ClickCount == 1)
        {
            // Open Informational Window
        }
        else if (e.ClickCount == 2)
        {
            // Select Item
        }
    }
}

Every time I doubleclick both // Only do MouseClick and // Only do MouseDoubleClick happens.

Is there any way to avoid this in WPF, .NET 4?

  • 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-18T09:47:33+00:00Added an answer on May 18, 2026 at 9:47 am

    Between first click and second click in double click I think there is a time around 50 and 400 millisecond, So the bellow code is not a best one but do the trick:

    bool firstClicked = false;
    
        protected override void OnMouseUp(MouseButtonEventArgs e)
        {
            base.OnMouseUp(e);
            if (e.ClickCount == 1)
            {
                firstClicked = true;
                Task tsk = new TaskFactory()
                                .StartNew(
                                () => 
                                    {
                                        Thread.Sleep(SystemInformation.DoubleClickTime);
                                        if (firstClicked)
                                        {
                                            // if you want to use `e`
                                            // e.Source
                                            // Open Informational Window
                                        }
                                            firstClicked = false;
                                        }
                                            );
    
                                    }
    
            }
            else if (e.ClickCount == 2)
            {
                firstClicked = false;
                // Select Item
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple WPF (XAML) file that has some animated shapes and text.
WPF doesn't provide the ability to have a window that allows resize but doesn't
I have a wpf application that has some shapes on a canvas I want
I have a custom WPF Line, that I whant to change the Style when
WPF VS 2010 C# Have a window where the beginning of the code behind
I'm trying to create a WPF Shape (PolyLine) editor, which is a control that
WPF GridSplitter makes my Grid wider than my Window! I've got a WPF Grid
Using WPF, I have a TreeView control that I want to set its ItemTemplate
Many applications have dialogs which have totally custom-looking dialogs, big fat tool-bars and non-rectangular
I need to write a gauge control in WPF for a project at work.

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.