Distinguish betweem clicking and dragging

Oct 18, 2009 at 12:29 PM

Hey Kevin,

is there any way to distinguish between clicking and dragging? I have a context menu which should be displayed on left mouse click but shouldn't when I do dragging.


Anton Kalcik

Nov 2, 2009 at 10:06 AM
Hello, as both your menu as the starting of a drag is initiated by a left mouse button click, I think this might be pretty hard to do... You could modify the source so the dragging only starts after the user "moved" the mouse while the left mouse button is down, but that would mean dragging would probably feel quite weird to the user. Kind regards, Kevin.
Aug 21, 2011 at 2:26 PM

 //mouse down 


//Handle left or right mouse buttons up event

clickTime =DateTime



//dragsource that should be replaced

Button_Down_at = e.GetPosition(element);



//mouse up

DateTime clickTimeUp = DateTime.Now;







span = clickTimeUp - clickTime; 

Point Button_Up_at = e.GetPosition(element); 

if(span.TotalMilliseconds < 500 &&

mouseDown && 

Math.Abs(Button_Down_at.X - Button_Up_at.X) < 4 && Math

.Abs(Button_Down_at.Y - Button_Up_at.Y) < 4)

ListContent toBeReplacedContent = (ListContent)(((DragSource)sender).DataContext); .Relative));



NavigationService.Navigate(new Uri("/page2.xaml", UriKind