日期:2014-05-17 浏览次数:20830 次
public class CustomImageControl : Image
{
private const int nHoverTimeSenconds = 2;
private const int nHoverTimeMilliseconds = 0;
private DispatcherTimer timeHover;
public CustomImageControl()
: base()
{
timeHover = new DispatcherTimer();
timeHover.Tick += (sender, e) =>
{
// 些处想触发 OnMouseUp 事件,应该怎么写。
System.Windows.MessageBox.Show("Yes");
};
timeHover.Interval = new TimeSpan(0, 0, 0, nHoverTimeSenconds, nHoverTimeMilliseconds);
}
protected override void OnMouseEnter(System.Windows.Input.MouseEventArgs e)
{
base.OnMouseEnter(e);
timeHover.Start();
}
protected override void OnMouseLeave(System.Windows.Input.MouseEventArgs e)
{
base.OnMouseLeave(e);
timeHover.Stop();
}
}