Normally, double-click does not exist in Silverlight.But within a period of time after you press the left button pressing the left button double click event in a more duration 300 ms.
public partial class Page : UserControl
{
DispatcherTimer timer;
public Page()
{
InitializeComponent();
Loaded += new RoutedEventHandler(Page_Loaded);
}
void Page_Loaded(object sender, RoutedEventArgs e)
{
timer = new DispatcherTimer();
timer.Interval = TimeSpan.FromMilliseconds(300);
timer.Tick += new EventHandler(timer_Tick);
}
void timer_Tick(object sender, EventArgs e)
{
timer.Stop();
}
private void Image_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
if (timer.IsEnabled)
{
MessageBox.Show("Double Clicked.");
}
else
{
timer.Start();
}
}
}
No comments:
Post a Comment