Click or drag to resize

DynamicLayout Class

Dynamic and extensible layout
Inheritance Hierarchy

Namespace:  Eto.Forms
Assembly:  Eto (in Eto.dll) Version: 2.5.3-dev
Syntax
[ContentPropertyAttribute("Rows")]
public class DynamicLayout : Panel

The DynamicLayout type exposes the following members.

Constructors
Properties
  NameDescription
Public propertyControls
Gets an enumeration of controls that are directly contained by this container
(Overrides PanelControls.)
Public propertyDefaultPadding
Gets or sets the default padding for all child DynamicTable instances (vertical sections)
Public propertyDefaultSpacing
Gets or sets the default spacing for all cells in the layout
Public propertyIsCreated
Gets a value indicating whether the layout has been created
Public propertyPadding
Gets or sets the padding around the entire content of the layout
Public propertyRows
Gets or sets the top level rows in the layout
Public propertySpacing
Gets or sets the spacing between the first level of cells
Public propertyVisualControls
Gets an enumeration of controls that are in the visual tree.
(Overrides ControlVisualControls.)
Top
Methods
  NameDescription
Public methodAdd
Add the control with the optional scaling
Public methodAddAutoSized
Adds a control to the layout with its preferred size instead of taking the entire space of the cell
Public methodAddCentered
Adds a control centered in a new vertical section
Public methodAddColumn
Adds a column of controls in a new vertical section
Public methodAddRange(Control)
Adds a list of controls
Public methodAddRange(IEnumerableControl)
Adds a list of controls
Public methodAddRow
Adds a new row of controls to the current vertical section
Public methodAddSeparateColumn(Control)
Adds a separate vertical column of items in a new vertical section
Public methodAddSeparateColumn(NullablePadding, NullableInt32, NullableBoolean, NullableBoolean, IEnumerableControl)
Adds a separate vertical column of items in a new vertical section
Public methodAddSeparateRow(Control)
Adds a separate horizontal row of items in a new vertical section
Public methodAddSeparateRow(NullablePadding, NullableSize, NullableBoolean, NullableBoolean, IEnumerableControl)
Adds a separate horizontal row of items in a new vertical section
Public methodAddSpace
Adds an empty space. Equivalent to calling Add(null);
Public methodBeginCentered
Creates a new section where all controls will be centered together.
Public methodBeginGroup
Begins a the group section in the dynamic layout with a title.
Public methodBeginHorizontal
Begins a new horizontal row section
Public methodBeginScrollable
Begins a the scrollable section in the dynamic layout with a specified border.
Public methodBeginVertical
Begins a new vertical section in the layout
Public methodClear
Clears the layout so it can be recreated
Public methodCreate
Creates the layout content
Public methodEndBeginHorizontal
Ends the current horizontal section, then begins a new horizontal section with a new row
Public methodEndBeginVertical
Ends the current vertical section, then begins a new vertical section
Public methodEndCentered
Ends the current centered section.
Public methodEndGroup
Ends a group.
Public methodEndHorizontal
Ends the current horizontal section
Public methodEndScrollable
Ends a scrollable section.
Public methodEndVertical
Ends the current vertical section
Protected methodOnLoad
Raises the Load event, and creates the layout if it has not been created
(Overrides ContainerOnLoad(EventArgs).)
Protected methodOnPreLoad
Raises the PreLoad event, and creates the layout if it has not been created
(Overrides ContainerOnPreLoad(EventArgs).)
Top
Remarks
The dynamic layout allows you to build a complex structure of controls easily. The core functionality allows you to build a hierarchical set of tables with rows and columns of controls. A vertical section begins a new table, whereas a horizontal section refers to a row in a table. The dynamic layout intrinsically starts with a vertical section. You can define your layout verbosely or succinctly as you see fit. The Begin.../End... methods allow you define the vertical/horizontal sections individually with separate commands, whereas you can also create a layout entirely with a constructor or initializer pattern using the Rows, Rows, and Items properties. To learn about how scaling works, see TableLayout
Examples
This example uses the verbose methods creating sections in separate statements
var layout = new DynamicLayout();

layout.BeginHorizontal();
layout.Add(new Label { Text = "My Label" });
layout.Add(new TextBox());
layout.EndHorizontal();

layout.BeginHorizontal()
layout.Add(new Label { Text = "Vertical controls:" });

layout.BeginVertical(padding: new Padding(10));
layout.Add(new TextBox());
layout.Add(new Label { Text = "Some text below the text box" });
layout.EndVertical();

layout.EndHorizontal();
This example uses the constructor method:
var layout = new DynamicLayout(
    new DynamicRow(
        new Label { Text = "My Label" },
        new TextBox()
    ),
    new DynamicRow(
        new Label { Text = "Vertical controls:" },
        new DynamicTable(
            new TextBox(),
            new Label { Text = "Some text below the text box" }
        ) { Padding = new Padding(10) }
    )
);
And finally the initializer pattern, which allows you to set other properties of rows/tables cleaner, such as padding/spacing/scaling:
var layout = new DynamicLayout { Rows = {
    new DynamicRow { Items = {
        new Label { Text = "My Label" },
        new TextBox()
    } },
    new DynamicRow { Items = {
        new Label { Text = "Vertical controls:" },
        new DynamicTable { Padding = new Padding(10), Rows = {
            new TextBox(),
            new Label { Text = "Some text below the text box" }
        } }
    } }
} };
See Also