Class GridPlacement
Places elements in a Grid: a drop lands in the cell under the pointer, and a resize grows or shrinks
Grid.RowSpan/Grid.ColumnSpan as the dragged edge crosses into the next track.
public sealed class GridPlacement : MarginPlacement, IPlacementStrategy
- Inheritance
-
GridPlacement
- Implements
- Inherited Members
- Extension Methods
Remarks
Grid.Row, Grid.Column and the spans are written only when they differ from their defaults (0 and 1),
and removed when they return to them.
- On an axis the element stretches on, the dragged edge follows the pointer: the span ends in the track the edge is in, and the rest of that track becomes the margin on the dragged side. Within SnapDistance of a track line the edge snaps to the line, so whole-cell spans stay easy to hit.
- On an axis with an explicit size, the size follows the pointer, and the span grows once the edge reaches SpanThreshold into the next track.
Properties
OwnedAttributes
Gets the attributes that only mean something inside this kind of container, such as Grid.Row. They're
removed from an element that moves into a different container.
public override IReadOnlyList<string> OwnedAttributes { get; }
Property Value
SnapDistance
Gets or sets how close, in layout units, the dragged edge of a stretched element must come to a track line to
snap to it. Defaults to 8; 0 turns snapping off.
public float SnapDistance { get; set; }
Property Value
Remarks
Layout units are scaled with the rest of the UI (EffectiveScale), so the distance feels the
same at any display scale. The editor skips snapping while Alt is held.
Exceptions
- ArgumentOutOfRangeException
The value is negative or not a number.
SpanThreshold
Gets or sets how far, as a fraction of a track, the dragged edge of an element with an explicit size must reach
into the next track before the span grows to include it. Defaults to 0.25.
public float SpanThreshold { get; set; }
Property Value
Methods
BeginResize(PlacementContext, ResizeHandle)
Starts resizing an element of this container from handle.
public override IResizeOperation BeginResize(PlacementContext context, ResizeHandle handle)
Parameters
contextPlacementContextThe container and the element, as they were when the gesture started.
handleResizeHandleThe dragged handle.
Returns
- IResizeOperation
The operation to update while the pointer moves.
GetDropTarget(PlacementContext, Vector2)
Decides where an element dropped at point lands.
public override PlacementTarget? GetDropTarget(PlacementContext context, Vector2 point)
Parameters
contextPlacementContextThe container and the dragged element.
pointVector2Where the dragged element's top-left corner would be, in the container's local space.
Returns
- PlacementTarget
The target, or null when the container can't take the element.