在windows phone中,对于一个页面中 有图片列表的,滑动的时候,很容易被误认为是点击了图片,而打开图片详细信息等,原意是滑动列表,由此对图片添加2个事件,来控制其点击行为(滑动的时候,基本不会执行到do clicked something处)
private bool _isClickEnable = false;
private DateTime _clickedTime;
private void Img1_OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
_isClickEnable = true;
_clickedTime = DateTime.Now;
}
private void Image_MouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
if (!_isClickEnable) return;
//0.1秒内 对同一张图片 点击了 down,然后up 才能作为一次有效的点击
if (_clickedTime == null || _clickedTime.CompareTo(DateTime.Now.AddSeconds(-0.1)) <= 0) return;
_isClickEnable = false;
//do clicked something
}