If you’re adding an event handler from code, rather than specifying the handler in XAML, you can just use the += notation for an event that is defined for the control in question. For example, the Button control defines a Click control, so you can do the following:
myButton.Click += new RoutedEventHandler(Button_Click);
But let’s say that you want to add a handler for the Click event to a StackPanel control, which does not define the Click event, and you want to do it from code. You can then use the AddHandler syntax:
myStackPanel.AddHandler(ButtonBase.ClickEvent, (RoutedEventHandler)HandleTheClick);
Read more: 2,000 Things You Should Know About WPF
QR: ![Inline image 1](http://chart.googleapis.com/chart?chs=80x80&cht=qr&choe=UTF-8&chl=http://wpf.2000things.com/2012/07/03/593-addhandler-method-can-add-handler-for-any-event/)