AddHandler Method

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

Adds a routed-event handler for a specified routed event, adding the handler to the current element's event handler collection.

Namespace:  Microsoft.SPOT.Presentation
Assembly:  Microsoft.SPOT.TinyCore (in Microsoft.SPOT.TinyCore.dll)

Syntax

'Declaration
Public Sub AddHandler ( _
    routedEvent As RoutedEvent, _
    handler As RoutedEventHandler, _
    handledEventsToo As Boolean _
)
public void AddHandler(
    RoutedEvent routedEvent,
    RoutedEventHandler handler,
    bool handledEventsToo
)
public:
void AddHandler(
    RoutedEvent^ routedEvent, 
    RoutedEventHandler^ handler, 
    bool handledEventsToo
)
member AddHandler : 
        routedEvent:RoutedEvent * 
        handler:RoutedEventHandler * 
        handledEventsToo:bool -> unit 
public function AddHandler(
    routedEvent : RoutedEvent, 
    handler : RoutedEventHandler, 
    handledEventsToo : boolean
)

Parameters

  • handledEventsToo
    Type: System. . :: . .Boolean
    true if you want to register the handler such that it is invoked even when the routed event is marked handled in its event data; false if you want to register the handler with the default condition that it will not be invoked if the routed event is already marked handled. Note that the default value for this parameter is false. Do not routinely ask to rehandle a routed event. For more information, see the "Remarks" section on this page.

Remarks

Processing low-level input events in a practical way is a complex task. Many controls implement a behavior wherein a certain event is marked as handled and is replaced by another, more intuitive event. Generally, a control will mark a platform input event as handled only if there is some design intention for doing so. In certain scenarios, those design intentions might not be what your particular handling of the input event requires. It is for these scenarios that registering handlers with the handledEventsToo parameter set to true is appropriate. But you should not do this routinely. Invoking handlers in response to all events — even if they are handled events — will complicate your own application event processing logic. You may see a decrease in performance if the handler logic is substantial. You should reserve the use of attaching handlers for already handled events for situations in which you have already discovered during the development process that certain controls are handling events that you still want to handle with application logic.

You can add the same handler for the same event multiple times without raising an exception. However, the handler is actually invoked multiple times when the event is handled. Therefore, consider how this behavior might have side effects that you should account for in your handler implementation.

.NET Framework Security

See Also

Reference

UIElement Class

Microsoft.SPOT.Presentation Namespace