[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]
Represents the method that will handle an event that has no event data.
Assembly: mscorlib (in mscorlib.dll)
Public Delegate Sub EventHandler ( _ sender As Object, _ e As EventArgs _ )
public delegate void EventHandler( Object sender, EventArgs e )
The source of the event.
The event model in the .NET Framework is based on having an event delegate that connects an event with its handler. To raise an event, two elements are needed:
A delegate that identifies the method that provides the response to the event.
A class that holds the event data.
The delegate is a type that defines a signature, that is, the return value type and parameter list types for a method. You can use the delegate type to declare a variable that can refer to any method with the same signature as the delegate.
The standard signature of an event handler delegate defines a method that does not return a value, whose first parameter is of type Object and refers to the instance that raises the event, and whose second parameter is derived from type EventArgs and holds the event data. If the event does not generate event data, the second parameter is simply an instance of EventArgs. Otherwise, the second parameter is a custom type derived from EventArgs and supplies any fields or properties needed to hold the event data.
EventHandler is a predefined delegate that specifically represents an event handler method for an event that does not generate data. If your event does generate data, you must supply your own custom event data type and either create a delegate where the type of the second parameter is your custom type, or use the generic EventHandler<(Of <(TEventArgs>)>) delegate class and substitute your custom type for the generic type parameter.
To associate the event with the method that will handle the event, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate.
For more information about event handler delegates, see Events for Windows Phone 8
The following code example demonstrates the declaration of an event handler delegate that does not use event data. The EventHandler class is the type of the event delegate, sender is the object that raises the event, and e is an event data object that contains no data. The second line of code in the example defines the event member in your class for an event that has no data.
Delegate Sub EventHandler(ByVal sender As Object, ByVal e As EventArgs) Public Event NoDataEventHandler As EventHandler
public delegate void EventHandler(Object sender, EventArgs e); public event EventHandler NoDataEventHandler;
Windows Phone OS
Supported in: 8.1, 8.0, 7.1, 7.0