# AutoInitializeAttribute class

Namespace: [Eto](https://eto.picoe.ca/api/namespace/eto.md) · Assembly: [Eto](https://eto.picoe.ca/api/assembly/eto.md)

```cs
[AttributeUsage(AttributeTargets.Interface)]
public sealed class AutoInitializeAttribute : Attribute
```

Attribute to specify whether the handler interface should be initialized automatically

**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.

**Example:**

An example handler that implements this behaviour:

```cs
[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
	}
}
```

## Constructors

- [AutoInitializeAttribute](https://eto.picoe.ca/api/type/eto.autoinitializeattribute/ctor.md): Initializes a new instance of the [AutoInitializeAttribute](https://eto.picoe.ca/api/type/eto.autoinitializeattribute.md) class.

## Properties

- [Initialize](https://eto.picoe.ca/api/type/eto.autoinitializeattribute/initialize.md): Gets a value indicating whether to auto initialize the handler, false to defer this to the widget author
