Reputation: 7072
I have an application that I want to move the window the problem is that all images that had a preview mouse up now are not working.
This is the windo event:
private void Window_MouseDown(object sender, MouseButtonEventArgs e)
{
DragMove();
}
and this is the image event:
private void image1_PreviewMouseUp(object sender, MouseButtonEventArgs e)
{
MessageBox.Show("WTF IS WPF?");
}
If I remove the DragMove function the image event works.
Upvotes: 1
Views: 653
Reputation: 6316
why execute DragMove() all the time?
MouseButtonState _mouseButtonState;
private void Window_MouseDown(object sender, MouseButtonEventArgs e)
{
_mouseButtonState = e.ButtonState;
}
private void Window_MouseMove(object sender, MouseEventArgs e)
{
if(_mouseButtonState == MouseButtonState.Pressed)
DragMove();
}
I would also put a check in image1_PreviewMouseUp
private void image1_PreviewMouseUp(object sender, MouseButtonEventArgs e)
{
if(_dragging) return;
//else do your preview
}
Upvotes: 3