Class LayoutControl
The base of a control that holds other controls and arranges them: StackLayout, DockLayout and Grid.
public abstract class LayoutControl : UIElement, IUpdateable, IEquatable<IUpdateable>, IDrawable, IIdentifiable<Guid>, IEquatable<IDrawable>, IDisposable
- Inheritance
-
LayoutControl
- Implements
- Derived
- Inherited Members
Constructors
LayoutControl(ILogger, View, string)
Creates a layout in view.
protected LayoutControl(ILogger logger, View view, string id = null)
Parameters
Properties
Background
A texture drawn behind the children, filling this layout's bounds. Null for none.
public ITexture Background { get; set; }
Property Value
BackgroundColor
The tint applied to Background. White, the default, leaves the texture as it is.
public Color BackgroundColor { get; set; }
Property Value
Children
The controls in this layout, in the order they were added.
public List<UIElement> Children { get; }
Property Value
IsLayoutDirty
Whether the layout must arrange its children again. Adding or removing a child, or a child's size changing, sets it.
protected bool IsLayoutDirty { get; set; }
Property Value
Methods
AddChild(UIElement)
Adds child to this layout and marks the layout for arranging.
public virtual void AddChild(UIElement child)
Parameters
childUIElement
Exceptions
- ArgumentNullException
childis null.
ArrangeControls()
Sets the location and size of each child. Called when the layout is dirty.
protected abstract void ArrangeControls()
ClearChildren()
Disposes and removes every child.
public virtual void ClearChildren()
Dispose()
Disposes every child, removes them, and then disposes the layout.
public override void Dispose()
Draw(IGameTime)
Draws this layout's bounds and fill, then Background, then the visible children.
public override sealed void Draw(IGameTime gameTime)
Parameters
gameTimeIGameTime
FindById(string)
Returns the control with the id id from this layout's children, or from
the children of a child layout. Null when neither has it.
public UIElement FindById(string id)
Parameters
idstring
Returns
GetDesiredSize()
The size this layout asks for. A parent layout reads it to size this one. By default it is the current Size.
protected virtual Vector2 GetDesiredSize()
Returns
LoadContent()
Loads the content of every child.
public override void LoadContent()
RemoveChild(UIElement)
Removes child from this layout. The child is not disposed.
public virtual void RemoveChild(UIElement child)
Parameters
childUIElement
Exceptions
- ArgumentNullException
childis null.
Update(IGameTime)
Arranges the layout if it is dirty, then updates the children that are visible and enabled. It arranges again after the children, because some of them size themselves during their update.
public override void Update(IGameTime gameTime)
Parameters
gameTimeIGameTime