Remarks: Styles allow you to attach custom platform-specific logic to a widget. In your platform-specific assembly, use Style.Add<H>(string, StyleHandler<H>) to add the style logic with the same id. Typically, your styles will be added in your platform-specific executable, before your application is run.
Example:Style the widget, with no direct access to platform-specifics
Style.Add<Form>("mainForm", widget => {
widget.Title = "Hello!";
}); Style based on a platform-specific handler (this is for Mac OS X): Style.Add<Eto.Mac.Forms.FormHandler>("mainForm", handler => {
handler.Control.CollectionBehavior |= NSWindowCollectionBehavior.FullScreenPrimary;
});
Style.Add<Eto.Mac.Forms.ApplicationHandler>("application", handler => {
handler.EnableFullScreen ();
});
// create the UI (typically this is in your UI library, not in the platform-specific assembly)
var app = new Application {
Style = "application"; // will apply the style here
};
app.Initialized += delegate {
app.MainForm = new Form { Style = "mainForm" }; // apply the mainForm style
app.MainForm.Show ();
};Properties
Provider
#Gets or sets the style provider.
Remarks: By default, this is an instance of DefaultStyleProvider. If you set this value, any styles applied using Add<THandler>(string, StyleHandler<THandler>) or Add<TWidget>(string, StyleWidgetHandler<TWidget>) will no longer be used.
Value: The provider.
Methods
Add<THandler>
#Adds a style for a widget handler
Remarks: Styling a widget handler allows you to access both the widget and the platform-specifics for the widget. To use this, you would have to add a reference to one of the Eto.*.dll's so that you can utilize the platform handler directly. Typically this would be called before your application is run.
Parameters:
| style (string) | Identifier for the style |
| styleHandler (StyleHandler<THandler>) | Delegate with your logic to style the widget and/or platform control |
Add<TWidget>
#Adds a style for a widget
Remarks: Styling a widget allows you to access the widget, but not the platform-specific controls (in a type-safe way). Typically, you'd use Style.Add<H>(string, StyleHandler<H>) instead, which will add a style based on the widget handler, which will give you direct and type safe access to platform-specifics of the widget.
Parameters:
| style (string) | Identifier of the style |
| handler (StyleWidgetHandler<TWidget>) | Delegate with your logic to style the widget |
Events
StyleWidget
#Event to handle when a widget has being styled