Table of Contents

Interface IDragSource

Namespace
Icy.Input.DragDrop
Assembly
IcyUI.dll

Opts a UIElement into cross-container drag-and-drop (see DragDropSession) - separate from OnDragStarted(Point)/OnDragPerforming(Point)/ OnDragEnded(Point), which only ever support a single-target "hold and move the pointer" gesture within the one element that was originally hit (e.g. a Slider's thumb, or a future SplitPane's divider) - Canvas hit-tests once at drag-start and never again.

public interface IDragSource
Extension Methods

Remarks

A Canvas checks every element from the drag's hit leaf up through its ancestors (the same walk OnDragStarted(Point) already uses) for the first one implementing this interface whose TryBeginDrag(Point, out object?, out UIElement?) returns true - both mechanisms can coexist on the same gesture, since one is about a specific element moving itself and the other is about carrying data to a different element entirely.

Methods

TryBeginDrag(Point, out object?, out UIElement?)

Called once, when a drag gesture starts on this element (or a descendant).

bool TryBeginDrag(Point screenPoint, out object? payload, out UIElement? preview)

Parameters

screenPoint Point

The drag's starting position, in screen/window space.

payload object

The data to carry for the duration of the drag, made available to every IDropTarget considered along the way via Payload. Must be non-null when this method returns true.

preview UIElement

An optional element rendered via Overlays, repositioned to follow the cursor for the rest of the gesture and removed automatically once it ends. null draws no preview.

Returns

bool

true to begin a DragDropSession; false to decline (the gesture still proceeds as an ordinary single-target drag for any element that handles it that way).