Anup Shah on WPF and Silverlight (Programming Garden)

IT 's For You!!!

Wednesday, May 9, 2012

DataGrid Double Click Event in Silverlight



Click...Event
MouseLeftButtonUp="DataGrid_MouseLeftButtonUp"

Code...
UIElement element = sender as UIElement;
DateTime clickTime = DateTime.Now;

TimeSpan span = clickTime - _lastClick;
if (span.TotalMilliseconds > 300 || _firstClickDone == false)
{
       //"First click...";
       _clickPosition = e.GetPosition(element);
       _firstClickDone = true;
       _lastClick = DateTime.Now;
}
else
{
       Point position = e.GetPosition(element);
       if (Math.Abs(_clickPosition.X - position.X) < 4 && Math.Abs(_clickPosition.Y - position.Y) < 4) //mouse didn't move => Valid double click
       {                   
              //"Double click...";
              //######## LOGIC Code ########   
       }
       else
              // "Double Click failed due to mouse move!";
              _firstClickDone = false;
  }


Thanks & Regards,
www.galaxywebmind.com

No comments:

Post a Comment