WPF Tunneling, practical use?

What practical scenarios should event tunneling use?

I know that the vague answer to this may be that it is used when we want to process the event through the visual / logical object on which the event was created. But this is just a theory.

In practice, why should I tunnel an event?

Does tunneling (and spooling) work through a logical tree or a Visual tree, or both?

+5
source share
4 answers

, , , , , . , ItemsControl , . , ItemsControl, .

"" , , . , .

+8

WPF OnPreview. , , , .

, . , . , , , . , WPF , bubble, .

Msdn:

: . , node, (, ). , , . WPF, / . , , .

AFAIK Visual , MSDN , .

+4

MSDN:

: . , node, (, ). , , . WPF, / . , , .

- , Preview -events.

enter image description here

MSDN WPF: WPF. @Robert Havery , SO.

+2

, () (). " " .

As an example, if you created your own custom button style control, an icon could be part of the control. If the user must click the icon, you will catch the tunneling preview event because the icon does not need to know that it was clicked. Then you can raise a bubble event informing about any controls containing your button that was pressed.

+1
source

All Articles