Silverlight 鼠标双击 事件
Silverlight 双击事件例子
<UserControl x:Class="MouseDbClick.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400"> <Grid x:Name="LayoutRoot" Background="White">
<ListBox Height="100" HorizontalAlignment="Left" Margin="12,12,0,0" Name="lbTest" VerticalAlignment="Top" Width="120" />
</Grid>
</UserControl>
后台代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes; namespace MouseDbClick
{
public partial class MainPage : UserControl,IMouseDbClick
{ MouseDbClickHander hander = null; public MainPage()
{
InitializeComponent();
hander = new MouseDbClickHander(this);
lbTest.MouseLeftButtonDown += new MouseButtonEventHandler(lbTest_MouseLeftButtonDown);
lbTest.MouseLeftButtonUp += new MouseButtonEventHandler(lbTest_MouseLeftButtonUp);
string[] str = {"a","b","c","d" };
lbTest.ItemsSource = str;
} void lbTest_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
hander.OnMouseLeftButtonUp(sender, e);
} void lbTest_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
hander.OnMouseLeftButtonDown(sender, e);
} #region IMouseDbClick 成员 public void onMouseDbClick(object sender, MouseButtonEventArgs e)
{
string msg = lbTest.SelectedItem as string;
MessageBox.Show(msg);
} #endregion
}
}
实现双击的接口代码
using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes; namespace MouseDbClick
{
public interface IMouseDbClick
{
void onMouseDbClick(object sender, MouseButtonEventArgs e);
}
}
实现双击的代码
using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes; namespace MouseDbClick
{
public class MouseDbClickHander
{ public DateTime lastClick = DateTime.Now;
private bool firstClick = false;
private IMouseDbClick _mouseDbClick; // Methods
public MouseDbClickHander(IMouseDbClick mouseDbclick)
{
this._mouseDbClick = mouseDbclick;
}
public void OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{ }
public void OnMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
//UIElement ui = sender as UIElement;
TimeSpan span = DateTime.Now - lastClick;
if (span.TotalMilliseconds < || firstClick == false)
{
firstClick = true;
lastClick = DateTime.Now;
}
else
{
this._mouseDbClick.onMouseDbClick(sender, e);
firstClick = false;
}
} }
}
到了Silverlight5.0后鼠标事件中有一个ClickCount属性,可以判断是否是双击。
Silverlight 鼠标双击 事件的更多相关文章
- IE和Chrome执行javascript对鼠标双击事件的不同响应
最近在用天地图API帮同学做点开发的工作,主要是基于天地图的API实现违法用地举报的在线地图标绘,要实现的效果如下: 由于是基于天地图API的TPolygonTool工具实现面积量测和多边形绘制功能, ...
- EasyUI使用之鼠标双击事件
easyui鼠标双击事件,使用 onDblClickRow(index, row) 事件,在用户双击一行的时候触发,参数包括: index:点击的行的索引值,该索引值从0开始. row:对应于点击行的 ...
- 【原创】有关Silverlight DataGrid双击事件的分析 完整分析 代码与示例
公司项目用的silverlight,而且silverlight一些技术 资料比较少.所以分享出来 给大家参考参考. 有关Silverlight中DataGrid 双击事件 的代码 如下: 1. 前台x ...
- WPF 之 鼠标双击事件
由于WPF中没有鼠标的双击事件,因而只能通过MouseDown事件来模拟.当连续的两次MouseDown事件的时间间隔,没有超过一个设定的时间阈值时,就计算为一个双击事件,并作相应的处理. 利用WPF ...
- MFC鼠标单击截获鼠标双击事件,且无法记录单击的数据的解决方案
遇到的问题: 鼠标点击会截断鼠标双击的事件,无法保存椭圆的数据.也就是说双击执行的过程是OnLButtonDown,OnLButtonUp,OnLButtonDblClk,OnLButtonUp.并不 ...
- java列表组件鼠标双击事件的实现
Swing中提供两种列表组件,分别是列表框(JList)和组合框(JComboBox). 一.JList组件 构造方法: public JList():构造一个空的.具有只读模型的JList.publ ...
- Unity 如何检测鼠标双击事件
代码如下: void OnGUI(){ Event e=Event.current; )) Debug.Log("用户双击了鼠标"); }
- javascript模拟鼠标双击事件
通常我们在做开发的时候需要通过单击切换对立事件,简单做了一个模型. <!DOCTYPE html> <html> <head> <title>javas ...
- winform listbox增加鼠标双击事件
在Form.Designer.cs文件中对于listBox处理: listBox.MouseDoubleClick += new system.Windows.Forms.MouseEventHand ...
随机推荐
- Entity Framework Tutorial Basics(36):Eager Loading
Eager Loading: Eager loading is the process whereby a query for one type of entity also loads relate ...
- JAVA and JAVA WEB with TOMCAT and ECLIPSE 学习过程中遇到的字符乱码问题及解决方法汇总(随时补充)
JAVA语言具有跨平台,unicode字符集编码的特点. 但是在开发过程中处理数据时涉及到的字符编码问题零零散散,尤其是处理中文字符时一不留神就可能出现一堆奇奇怪怪的符号,俗称乱码. 对于乱码,究其原 ...
- React 和 Redux理解
学习React有一段时间了,但对于Redux却不是那么理解.网上看了一些文章,现在把对Redux的理解总结如下 从需求出发,看看使用React需要什么 1. React有props和state pro ...
- 【monkey测试】Fragment not attached to Activity
monkey测试跑出了一个异常: // CRASH: packgeName (pid) // Short Msg: java.lang.IllegalStateException // Long Ms ...
- sqlserver快速删除整个表数据
--删除整个表数据 SET STATISTICS TIME ON; DECLARE @Timer DATETIME = GETDATE(); TRUNCATE TABLE LOG_DEBUG_ERRO ...
- javascript使用ajax方式
ajax请回和回应实例: function showContent(type) { //create obj var xmlhttp; if (window.XMLHttpRequest) { //c ...
- C# Linq及Lamda表达式实战应用之 GroupBy 分组统计
在项目中做统计图表的时候,需要对查询出来的列表数据进行分组统计,首先想到的是避免频繁去操作数据库可以使用 Linq eg: //例如对列表中的Cu元素进行按年GroupBy分组统计 //包含年份,平均 ...
- Gazebo学习随记3 图形界面的使用
直接写模型的SDF文件实在是太反人类啦! 可以在gazebo图形界面中设置好模型的链接(碰撞外观惯性),关节等等参数-然后生成SDF文件
- UIPageViewController
前言 iPhone 和 iPad 都是通过页控件来展示多个桌面,很多 App 在第一次使用时也会使用页控件来介绍自己的功能,页控件的交互效果非常好,适用于把几个简单的页面充分展示出来. 1.UIPag ...
- #学习笔记# VALSE 2019.01.09 朱俊彦 --- Learning to Synthesize Images, Videos, and 3D Objects
视频类型:VALSE-webinar 报告时间:2019年01月09日 报告人:MIT朱俊彦 报告题目:Learning to Synthesize Images, Videos, and 3D Ob ...