.net - why no PreviewMouseEnter event is in WPF -


why there no such previewmouseenter event wpf?

question generic other nonexistent preview events.

or

why events direct event in wpf? can't make events routed events? have saved programming have do. example : treeview

were there disadvantages so?

it's because mouseenter not routed through element tree.

there 3 different routing strategies routed events:

  • bubbling: these events travelling upwards in element tree source of event, bubbles in pop. :)

  • tunneling: these events travelling downwards in element tree. these ones prefixed preview.

  • direct: source has chance handle event. mouseenter uses routing strategy.

the overview here gives better understanding answer.

update: theoretically see there nothing have prevented implementation of mouseenter bubbling or tunneling event. think design decision of developers of wpf. able find 1 reference in book "programming wpf: building windows ui windows presentation foundation" talks mouseenter event specifically.

direct events work normal .net events: handlers attached directly originating element notified - no real routing occurs. typically used events make sense in context of target element. example, unhelpful if mouse enter , leave events bubbled or tunneled - parent element unlikely care when mouse moves 1 child element another. @ parent element, expect "mouse leave" mean "the mouse has left parent element", , beacuse direct event routing used, that's mean. if bubbling used, event mean "the mouse has left element inside parent, , inside element may or may not inside parent," less useful.

source


Comments