Table of Contents

Method Fill

Namespace
Terminal.Gui.ViewBase
Assembly
Terminal.Gui.dll

Fill()

Creates a Dim object that fills the dimension, leaving no margin.

public static Dim Fill()

Returns

Dim

The Fill dimension.

Examples

var view = new View { X = 5, Y = 0, Width = Dim.Fill(), Height = 1 };
// If SuperView width is 80, view width will be 75 (80 - 5)

Remarks

The view will fill from its position to the end of the SuperView's content area.

If the SuperView uses Auto(DimAutoStyle, Dim?, Dim?), a DimFill SubView does not contribute to the auto-sizing calculation and will receive a size of 0. Use Fill(Dim, Dim?) with a minimumContentDim or Fill(View) with a to parameter to ensure the SubView contributes to auto-sizing. See the Dim.Auto Deep Dive for details.

Fill(Dim)

Creates a Dim object that fills the dimension, leaving the specified margin.

public static Dim Fill(Dim margin)

Parameters

margin Dim

Margin to use.

Returns

Dim

The Fill dimension.

Examples

var view = new View { X = 0, Y = 0, Width = Dim.Fill(2), Height = 1 };
// If SuperView width is 80, view width will be 78 (80 - 2)

Remarks

If the SuperView uses Auto(DimAutoStyle, Dim?, Dim?), a DimFill SubView does not contribute to the auto-sizing calculation and will receive a size of 0. Use Fill(Dim, Dim?) with a minimumContentDim or Fill(View) with a to parameter to ensure the SubView contributes to auto-sizing. See the Dim.Auto Deep Dive for details.

Fill(Dim, Dim?)

Creates a Dim object that fills the dimension, leaving the specified margin and respecting the specified minimum dimension.

public static Dim Fill(Dim margin, Dim? minimumContentDim)

Parameters

margin Dim

Margin to use.

minimumContentDim Dim

The minimum dimension. If null, no minimum is enforced.

Returns

Dim

The Fill dimension.

Examples

// Fill with minimum width of 40
var view = new View { X = 0, Y = 0, Width = Dim.Fill(margin: 0, minimumContentDim: 40), Height = 1 };
// If SuperView has Dim.Auto() width, it will be at least 40 wide
// If SuperView is 80 wide, view will be 80 wide
// If SuperView is 30 wide, view will still be 40 wide (minimum)

Remarks

When the SuperView uses Auto(DimAutoStyle, Dim?, Dim?), a DimFill SubView does not contribute to the auto-sizing calculation by default. The minimumContentDim parameter resolves this: it contributes a floor to the auto-sizing calculation, ensuring the SuperView is at least large enough to accommodate the minimum. Without it (or without using Fill(View) with a to parameter), the SubView will receive a size of 0.

See the Dim.Auto Deep Dive for details.

Fill(View)

Creates a Dim object that fills the dimension up to the position of another view.

public static Dim Fill(View to)

Parameters

to View

The view to fill up to.

Returns

Dim

The Fill dimension.

Examples

var label = new Label { X = 0, Y = 0, Width = 10, Text = "Name:" };
var btn = new Button { X = Pos.AnchorEnd(), Text = "OK" };
var textField = new TextField { X = Pos.Right(label) + 1, Y = 0, Width = Dim.Fill(to: btn) };
// textField will fill the space between the label and the button

Remarks

The view will fill from its position up to (but not including) the position of the to view. For Width, this means filling up to the X coordinate of the to view. For Height, this means filling up to the Y coordinate of the to view.

When the SuperView uses Auto(DimAutoStyle, Dim?, Dim?), this DimFill with to parameter does contribute to the auto-sizing calculation by ensuring the SuperView is large enough to accommodate both this view and the to view.

Fill(Dim, View)

Creates a Dim object that fills the dimension up to the position of another view, with a margin.

public static Dim Fill(Dim margin, View to)

Parameters

margin Dim

Margin to use.

to View

The view to fill up to.

Returns

Dim

The Fill dimension.

Examples

var btn = new Button { X = Pos.AnchorEnd(), Text = "OK" };
var textField = new TextField { X = 0, Y = 0, Width = Dim.Fill(margin: 2, to: btn) };
// textField will fill the space up to 2 columns before the button

Remarks

The view will fill from its position up to (but not including) the position of the to view, minus the specified margin.

When the SuperView uses Auto(DimAutoStyle, Dim?, Dim?), this DimFill with to parameter does contribute to the auto-sizing calculation by ensuring the SuperView is large enough to accommodate both this view and the to view.

Fill(Dim, Dim?, View)

Creates a Dim object that fills the dimension up to the position of another view, with a margin and minimum dimension.

public static Dim Fill(Dim margin, Dim? minimumContentDim, View to)

Parameters

margin Dim

Margin to use.

minimumContentDim Dim

The minimum dimension. If null, no minimum is enforced.

to View

The view to fill up to.

Returns

Dim

The Fill dimension.

Remarks

The view will fill from its position up to (but not including) the position of the to view, minus the specified margin, while respecting the minimum dimension.

When the SuperView uses Auto(DimAutoStyle, Dim?, Dim?), this DimFill with to parameter does contribute to the auto-sizing calculation by ensuring the SuperView is large enough to accommodate both this view and the to view. If minimumContentDim is also specified, both constraints contribute to the calculation.