Click or drag to resize

AutoInitializeAttribute Class

Attribute to specify whether the handler interface should be initialized automatically
Inheritance Hierarchy

Namespace:  Eto
Assembly:  Eto (in Eto.dll) Version: 2.5.3-dev
Syntax
[AttributeUsageAttribute(AttributeTargets.Interface)]
public sealed class AutoInitializeAttribute : Attribute

The AutoInitializeAttribute type exposes the following members.

Constructors
  NameDescription
Public methodAutoInitializeAttribute
Initializes a new instance of the AutoInitializeAttribute class.
Top
Properties
  NameDescription
Public propertyInitialize
Gets a value indicating whether to auto initialize the handler, false to defer this to the widget author
Top
Remarks
Handler interfaces that defer creation of the control to various Create() methods can apply this attribute so that the initialization can be done afterwards. If auto initialization is disabled, the widget author must call Widget.Initialize() after the control is created. Initialization applies styles to the widget and the handler, sets up events based on overridden event methods, etc. This is only needed by widget authors in advanced scenarios. The default is to auto initialize, so this is only needed if you want to disable this behaviour.
Examples
An example handler that implements this behaviour:
[AutoInitialize(false)]
public interface IMyWidget : IControl
{
    void CreateWithParams(int param1, bool param2);
}

[Handler(typeof(IMyWidget))]
public class MyWidget : Control
{
    public MyWidget(int param1, bool param2)
    {
        ((IMyWidget)Handler).CreateWithParams(param1, param2);
        Initialize(); // ensure you call this on any constructor of your widget
    }
}
See Also

Reference