This is how:
Having, for example, a class
public class MyClass {
public MyClass() {
}
public event System.EventHandler<SomeEventArgs> SomeEvent;
}
you can have an instance of this class and add an event handle to the
invocation list of the event instance, once or several times:
MyClass instance = MyClass();
instance.SomeEvent += (sender, eventArgs) => {
};
instance.SomeEvent += (sender, eventArgs) => {
DoSomethingElse(eventArgs);
};
where
eventArgs
is of the type
SomeEventArgs
, derived from
System.EventArgs
.
Please see:
http://msdn.microsoft.com/en-us/library/vstudio/awbftdfh.aspx[
^],
http://msdn.microsoft.com/en-us/library/edzehd2t%28v=vs.110%29.aspx[
^].
See also my past answers:
UserControl custom event[
^],
WPF : How to Use Event in Custom Control[
^].
Everything discussed above is fully applied to WPF events. At the same time, WPF events have advanced classification with quite advanced features which go well beyond the current topic, but this matter is good to know:
http://msdn.microsoft.com/en-us/library/ms753115%28v=vs.110%29.aspx[
^].
—SA