龙空技术网

Silverlight开发没有双击事件,如何实现呢?

訶綺紀莱 11

前言:

今天我们对“aspnetsilverlight”大概比较珍视,看官们都需要剖析一些“aspnetsilverlight”的相关资讯。那么小编在网摘上收集了一些关于“aspnetsilverlight””的相关资讯,希望姐妹们能喜欢,各位老铁们快快来学习一下吧!

不多废话,直接上代码:

Silverlight中自己定义实现的双击方法

private DateTime lastClickTimeTabItem;

private Point lastPointionTabItem; //Point为结构体,无须实例化

private void lblItem_MouseLeftButtonDown(object sender,MouseButtonEventArgs e){

//判断是否构成双击

  DateTime utcNow = DateTime.UtcNow;

Point position = e.GetPosition((UIElement)sender);

TimeSpan span = (TimeSpan)(utcNow - lastClickTimeTabItem);

double totlaMillisecondes = span.TotlaMillisecondes;

Double num2 = position.X - lastPointionTabItem.X;

Double num3 = position.Y - lastPointionTabItem.Y;

double num4 = (num2*num2) + (num3*num3);

if(totlaMillisecondes < 500.0 && num4 < 9.0){

  //////

}

this.lastClickTimeTabItem = utcNow;

this.lastPointionTabItem = position;

}

大神们如有更好的,请多多指教!

标签: #aspnetsilverlight