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

The Archive Base Latest Questions

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

I can find only MouseDown Event and MouseUp Event on a image in WPF.

  • 0

I can find only MouseDown Event and MouseUp Event on a image in WPF.
This causes some problem if I do MouseDown on some Image, Move the mouse and MouseUp event happens on some other image.
Is there any other event that I can use to solve this problem. like MouseClick Event for Button element.

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

    If you really must use an image then there’s a couple of things you can do to check for a “click”.

    1. Check the time between the two events. If it’s less than your threshold, then treat the mouse up as a click. You’ll need to store the time of the mouse down event.

    2. Check that the sender of both events is the same. Again you’ll need to store the sender of the mouse down event.

    You might also want to check that it’s the left button that’s been pressed and released.

    Combining the two:

        private DateTime downTime;
        private object downSender;
    
        private void Image_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (e.LeftButton == MouseButtonState.Pressed)
            {
                this.downSender = sender;
                this.downTime = DateTime.Now;
            }
        }
    
        private void Image_MouseUp(object sender, MouseButtonEventArgs e)
        {
            if (e.LeftButton == MouseButtonState.Released &&
                sender == this.downSender)
            {
                TimeSpan timeSinceDown = DateTime.Now - this.downTime;
                if (timeSinceDown.TotalMilliseconds < 500)
                {
                    // Do click
                }
            }
        }
    

    There’s actually a third thing you can do: Check the mouse position.

        private Point downPosition;
    

    save the position:

        this.downPosition = e.GetPosition(sender as Image);
    

    then check it in the MouseUp event, again with a tolerance value.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

data1/data2/data3 How can I find and replace all cells with this format to only
This is only tangentially a programming question. Where can I find a simple-to-parse list
I can only find validation checks like this? <input required pattern=^d{3}-d{2}-d{4}$ title=###-##-#### /> Is
I can only find asynchronous iPad/objective C HTTP examples. How do I do a
I've read through the SASS documentation and can only find how to do a
I've searched the web, and I can only find marketing material on .net 4.
I cannot somehow import the play.db.jpa.Model lib into my Model, it can only find
I'm trying to add Jumplist support to my app, but I can only find
I've been looking into multi-module projects in Maven, and I can only find examples
I just started writing powershell scripts for Citrix XenServer. However, I can only find

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.