Method AnchorEnd
AnchorEnd()
Creates a Pos object that is anchored to the end (right side or bottom) of the SuperView's content area. The view will be positioned so its right/bottom edge aligns with the SuperView's right/bottom edge.
public static Pos AnchorEnd()
Returns
Examples
This sample shows how to align a Button to the bottom-right of the SuperView.
anchorButton.X = Pos.AnchorEnd ();
anchorButton.Y = Pos.AnchorEnd ();
This sample shows how AnchorEnd() affects Auto(DimAutoStyle, Dim?, Dim?):
View superView = new () { Width = Dim.Auto () };
// Label contributes ~10 to width
Label label = new () { Text = "Name:" };
superView.Add (label);
// Button forces SuperView to be wide enough to fit it at the end
Button button = new ()
{
Text = "OK",
X = Pos.AnchorEnd () // SuperView width = button position + button width
};
superView.Add (button);
Remarks
When used within a SuperView that has Auto(DimAutoStyle, Dim?, Dim?), AnchorEnd() actively contributes to determining the SuperView's content size, ensuring the SuperView is large enough to accommodate the anchored view at the end position.
This is equivalent to using AnchorEnd(int) with an offset equal to the view's width (for X) or height (for Y).
AnchorEnd(int)
Creates a Pos object that is anchored to the end (right side or bottom) of the SuperView's content area, with a specified offset from the edge.
public static Pos AnchorEnd(int offset)
Parameters
offsetintThe number of columns (for X) or rows (for Y) from the right/bottom edge. The view will be positioned this many cells away from the edge, towards the start.
Returns
Examples
This sample shows how to position a Button 2 columns from the right edge.
// If SuperView width is 80, button will be at X = 80 - 2 = 78
button.X = Pos.AnchorEnd (2);
button.Y = 1;
This sample shows how AnchorEnd(int) affects Auto(DimAutoStyle, Dim?, Dim?):
View superView = new () { Width = Dim.Auto () };
// Button forces SuperView to be at least 12 columns wide (10 offset + 2 for margin)
Button button = new ()
{
Text = "OK",
Width = 2,
X = Pos.AnchorEnd (10) // SuperView width = 10 + some additional space
};
superView.Add (button);
Remarks
When used within a SuperView that has Auto(DimAutoStyle, Dim?, Dim?), AnchorEnd(int) actively contributes to determining the SuperView's content size, ensuring the SuperView is large enough to accommodate the anchored view at the calculated position.
See also AnchorEnd(), which uses the view's dimension to ensure the view is fully visible with its right/bottom edge aligned to the SuperView's edge.