Share via


UIElement.AddHandler Method

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

public void AddHandler (
         RoutedEventroutedEvent,
         Delegatehandler,
         boolhandledEventsToo
)

Parameters

  • routedEvent
    An identifier for the routed event to be handled.
  • handler
    A delegate that represents the handler to be added.
  • handledEventsToo
    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.

Version Information

Available in .NET Micro Framework version 2.0, 2.5

See Also

Reference

UIElement Class
UIElement Members
Microsoft.SPOT.Presentation Namespace