Class PosAnchorEnd
Represents a position anchored to the end (right side or bottom) of the SuperView's content area.
public record PosAnchorEnd : Pos, IEquatable<Pos>, IEquatable<PosAnchorEnd>
- Inheritance
-
PosAnchorEnd
- Implements
- Inherited Members
Examples
// Position a button 2 columns from the right edge
button.X = Pos.AnchorEnd (2);
// Position a view exactly at the bottom (accounting for its height)
view.Y = Pos.AnchorEnd ();
Remarks
PosAnchorEnd positions a view relative to the end (right edge for X, bottom edge for Y) of the SuperView's content area, accounting for the view's own dimension.
When used within a SuperView that has Auto(DimAutoStyle, Dim?, Dim?), PosAnchorEnd actively contributes to determining the SuperView's content size. The Auto(DimAutoStyle, Dim?, Dim?) algorithm calculates the minimum content size needed to accommodate views positioned with PosAnchorEnd.
How PosAnchorEnd affects Dim.Auto:
View superView = new () { Width = Dim.Auto () };
// This label contributes ~10 to the SuperView's width
Label label = new () { Text = "Name:" };
superView.Add (label);
// This TextField does NOT force the SuperView wider - Dim.Fill doesn't contribute to Dim.Auto
TextField field = new () { Y = 1, Width = Dim.Fill () };
superView.Add (field);
// This button WILL force the SuperView to be wide enough to accommodate it at the right edge
Button button = new ()
{
Text = "OK",
X = Pos.AnchorEnd (), // ← SuperView width must accommodate this position!
Y = 2
};
superView.Add (button);
// Result: SuperView width = Max (label width, button position + button width)
// The TextField fills whatever width the SuperView ends up being
The calculation works by determining the content size needed such that when the view is positioned at the end, it still fits within the content area. See DimAuto for details on how the auto-sizing algorithm processes anchored views.
This is a low-level API that is typically used internally by the layout system. Use the various static methods on the Pos class to create Pos objects instead.
Constructors
- PosAnchorEnd()
Constructs a new position anchored to the end (right side or bottom) of the SuperView's content area, offset by the view's respective dimension. This positions the view so its right/bottom edge aligns with the SuperView's right/bottom edge.
- PosAnchorEnd(int)
Constructs a new position anchored to the end (right side or bottom) of the SuperView's content area, with a specified offset from that edge.
Properties
- Offset
Gets the offset of the position from the right/bottom edge of the SuperView's content area.
- UseDimForOffset
If true, the offset is the width/height of the view. If false, the offset is the Offset value.
Methods
- ToString()
Returns a string that represents the current object.