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

Friday, May 4, 2012

How do I retrieve command-line arguments in my WPF application?


Command-line arguments are typically retrieved via a string array parameter passed to Main,
but the common way to define WPF applications doesn’t allow you to implement the Main
method. You can get around this in two different ways. One way is to forego defining an
Application-derived class in XAML, so you can manually define the Main method with a
string array parameter. The easier way, however, is to simply call
System.Environment.GetCommandLineArgs at any point in your application, which returns
the same string array you’d get inside Main.

How do I retrieve command-line arguments in my WPF application?


Command-line arguments are typically retrieved via a string array parameter passed to Main,
but the common way to define WPF applications doesn’t allow you to implement the Main
method. You can get around this in two different ways. One way is to forego defining an
Application-derived class in XAML, so you can manually define the Main method with a
string array parameter. The easier way, however, is to simply call
System.Environment.GetCommandLineArgs at any point in your application, which returns
the same string array you’d get inside Main.