Click or drag to resize

WidgetRegisterEventT Method

Registers the event for overridding

Namespace:  Eto
Assembly:  Eto (in Eto.dll) Version: 2.4.0
Syntax
protected static void RegisterEvent<T>(
	Expression<Action<T>> method,
	string identifier
)

Parameters

method
Type: System.Linq.ExpressionsExpressionActionT
Expression to call the method that raises your event
identifier
Type: SystemString
Identifier of the event

Type Parameters

T
Your object type
Remarks
This is used to register an event that will be automatically hooked up when a derived class overrides the event method. This should be called in the static constructor of your class.
Examples
Shows a custom control with an event:
public class MyEtoControl : Eto.Forms.Control
{
    public const string MySomethingEvent = "MyEtoControl.MySomethingEvent";

    public event EventHandler<EventArgs> MySomething
    {
        add { Properties.AddHandlerEvent(MySomethingEvent, value); }
        remove { Properties.RemoveEvent(MySomethingEvent, value); }
    }

    protected virtual void OnMySomething(EventArgs e)
    {
        Properties.TriggerEvent(MySomethingEvent, this, e);
    }

    static MyEtoControl()
    {
        RegisterEvent<MyEtoControl>(c => c.OnMySomething(null), MySomethingEvent);
    }
}
See Also