Class Pos
Describes the position of a View which can be an absolute value, a percentage, centered, or relative to the ending dimension. Integer values are implicitly convertible to an absolute Pos. These objects are created using the static methods Percent, AnchorEnd, and Center. The Pos objects can be combined with the addition and subtraction operators.
public abstract record Pos : IEquatable<Pos>
- Inheritance
-
Pos
- Implements
- Derived
- Inherited Members
Remarks
Use the Pos objects on the X or Y properties of a view to control the position.
These can be used to set the absolute position, when merely assigning an integer value (via the implicit integer to Pos conversion), and they can be combined to produce more useful layouts, like: Pos.Center - 3, which would shift the position of the View 3 characters to the left after centering for example.
Reference coordinates of another view by using the methods Left(View), Right(View), Bottom(View), Top(View). The X(View) and Y(View) are aliases to Left(View) and Top(View) respectively.
Pos Object | Description |
---|---|
Align(Alignment, AlignmentModes, int) | Creates a Pos object that aligns a set of views. |
Func(Func<int>) | Creates a Pos object that computes the position by executing the provided function. The function will be called every time the position is needed. |
Percent(int) | Creates a Pos object that is a percentage of the width or height of the SuperView. |
AnchorEnd() | Creates a Pos object that is anchored to the end (right side or bottom) of the dimension, useful to flush the layout from the right or bottom. |
Center() | Creates a Pos object that can be used to center the View. |
Absolute(int) | Creates a Pos object that is an absolute position based on the specified integer value. |
Left(View) | Creates a Pos object that tracks the Left (X) position of the specified View. |
X(View) | Creates a Pos object that tracks the Left (X) position of the specified View. |
Top(View) | Creates a Pos object that tracks the Top (Y) position of the specified View. |
Y(View) | Creates a Pos object that tracks the Top (Y) position of the specified View. |
Right(View) | Creates a Pos object that tracks the Right (X+Width) coordinate of the specified View. |
Bottom(View) | Creates a Pos object that tracks the Bottom (Y+Height) coordinate of the specified View |
Methods
- Absolute(int)
Creates a Pos object that is an absolute position based on the specified integer value.
- Align(Alignment, AlignmentModes, int)
Creates a Pos object that aligns a set of views according to the specified Alignment and AlignmentModes.
- AnchorEnd()
Creates a Pos object that is anchored to the end (right side or bottom) of the SuperView's Content Area, minus the respective size of the View. This is equivalent to using AnchorEnd(int), with an offset equivalent to the View's respective dimension.
- AnchorEnd(int)
Creates a Pos object that is anchored to the end (right side or bottom) of the SuperView's Content Area, useful to flush the layout from the right or bottom. See also AnchorEnd(), which uses the view dimension to ensure the view is fully visible.
- Bottom(View)
Creates a Pos object that tracks the Bottom (Y+Height) coordinate of the specified View
- Func(Func<int>)
Creates a Pos object that computes the position by executing the provided function. The function will be called every time the position is needed.
- Has<T>(out T)
Indicates whether the specified type
T
is in the hierarchy of this Pos object.
- Left(View)
Creates a Pos object that tracks the Left (X) position of the specified View.
- Percent(int)
Creates a percentage Pos object
- Right(View)
Creates a Pos object that tracks the Right (X+Width) coordinate of the specified View.
Operators
- implicit operator Pos(int)
Creates an Absolute Pos from the specified integer value.