开发者

PreviewMouseDoubleClic handled ignored

I have a window containing a textBox.

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

Handler in the window开发者_JS百科:

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?


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜