Jitendra Jadav
Jitendra Jadav

Reputation: 923

How to make Image doubleclick event in C#

I am working on Silverlight application and I want to make Image mousedouble click event,but there is no inbuilt mousedouble click in image control so I can do this..

Thanks...!!

Upvotes: 0

Views: 878

Answers (2)

Shoaib Shaikh
Shoaib Shaikh

Reputation: 4585

The key to accomplishing this is to check for two things:

  1. Measure the TimeSpan between two mouse clicks. Verify it is less than around 300 milliseconds.
  2. Make certain the mouse has not moved more than a few pixels.

Try this http://www.michaelsnow.com/2010/05/10/silverlight-tip-of-the-day-17-double-click/

Regards.

Upvotes: 4

ChrisF
ChrisF

Reputation: 137148

The simplest way is to use a timer.

In the click event handler you have the following cases:

  1. No timer. This is the first click, so start the timer and store the cursor location if necessary.

  2. Timer running. This is potentially the second click. If the cursor hasn't moved then perform the single click action. Stop the timer.

The timer should stop itself after the double click interval (500 ms say) has expired.

Upvotes: 0

Related Questions