0

I have a window containing a textBox.

On both the window AND the textBox, I add a PreviewMouseDoubleClicHandler.

Handler in the window:

private void PreviewMouseDoubleClickHandler(object sender, MouseButtonEventArgs e)
{
    Debug.WriteLine("handler in the window");
    e.Handled = true;
}

handler in the textBox:

private void PreviewMouseDoubleClickHandler(object sender, MouseButtonEventArgs e)
{
    Debug.WriteLine("handler in the textBox");
    e.Handled = true;
}

now, when I double-click on the textBox, I expect to go first into the window's Handler, print the debug line, then handle the event, then nothing more. I thought the textBox's handler would not fire since the event has already been handled by the window.

This does not work like this though: I get both handlers fired.

The weird thing is: It works fine with the PreviewMouseDown event. If I do exactly the same thing but with PreviewMouseDownEvents, I get the behavior I expect, i.e.: the window handles the mouseDown and the textBox's handler is not fired.

so Why does this not work with the doubleClick event? Am I doing something wrong? Is it supposed to work like this? is the doubleClick Event managed in a different way that prevents me from using the advantages of tunneling?

David
  • 6,014
  • 4
  • 39
  • 55

1 Answers1

1

The behavior is by design, please see: http://msdn.microsoft.com/en-us/library/system.windows.controls.control.previewmousedoubleclick.aspx

  • yes, I already have the mouseButtonDown + clickCount option as a backup solution, but in my case this would really be overkill and I wanted to know if I could make things work with the doubleClickEventHandler. Really weird that you can't use tunneling with the double-click. :-/ – David Feb 16 '11 at 10:42
  • This behavior is actually by design, as per MSDN: http://msdn.microsoft.com/en-us/library/system.windows.controls.control.previewmousedoubleclick.aspx –  Feb 16 '11 at 12:29
  • write this as an answer, I'll mark you as accepted. This is the piece of info I was missing (I really should RTFM) – David Feb 16 '11 at 13:07