AddHandler Method

Overload List

OverloadDescription
AddHandler(UIElement,String,Delegate)Adds an event handler for a non-routed event.  
AddHandler(UIElement,RoutedEvent,Delegate)Adds an event handler for a routed event.  

Remarks

If other handlers exist for the event, the handler added with AddHandler is called first.

To add a handler for a routed event, use AddHandler(UIElement,RoutedEvent,Delegate). To add a handler for a non-routed event, use AddHandler(UIElement,String,Delegate). Check the event documentation in MSDN to determine whether it is routed or not.

Handlers added with this method are released by the UFT infrastructure.

Example

C#Copy Code
private EventHandler<SelectionChangedEventArgs> _hSelectedDatesChanged; 
private RoutedEventHandler _hGotFocus; 
RecordInit() 

    _hSelectedDatesChanged = new EventHandler<SelectionChangedEventArgs>(MyCalendar_SelectedDatesChanged); 
    AddEventHandler(UtilityObject.ApplicationObject as UIElement, "SelectedDatesChanged", _hSelectedDatesChanged); 
 
    _hGotFocus = new RoutedEventHandler(MyCalendar_GotFocus); 
     AddEventHandler(UtilityObject.ApplicationObject, Calendar.GotFocusEvent, _hGotFocus); 

 
void MyCalendar_GotFocus(object sender, RoutedEventArgs e) 
{   

 
void  MyCalendar_SelectedDatesChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e) 


See Also