在文件浏览器选择图片时,如果图片位置刚好位于控件上:抬起鼠标或移动鼠标时控件会获取到鼠标事件,此时会导致图片移动,所以必须记录鼠标按下标志Flag_MouseDown。
private bool Flag_MouseDown;
private void ImageViewer_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
Flag_MouseDown = true;
}
private void ImageViewer_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
Flag_MouseDown = false;
}
private void ImageViewer_MouseMove(object sender, MouseEventArgs e)
{
if (Flag_MouseDown)
{
}
}