Skip to content

UIElement.AllowDrop property

Gets or sets whether the element accepts drops, taking part in drop-target hit testing and receiving DragEnter, DragOver, DragLeave and Drop.

public bool AllowDrop { get; set; }

Setting AllowDrop on a Window additionally registers the window for drags from other applications. What the platform delivers varies:

  • Windows: An STA UI thread gets the full protocol (DragEnter/Over/Leave/Drop, effect negotiation, native drag preview). .NET 6+ entry points default to MTA - apply [STAThread] on Main to opt in. On MTA threads only file drop arrives, with no enter/over/leave and no preview.
  • Linux: Every drag reaches the window with all the formats it offers.
  • macOS: A drag reaches the window when it carries files, a URL, text, HTML, rich text or an image; it then lists all the formats it offers.

On non-Window elements, AllowDrop only affects element-chain participation - element-level DragEnter/Over/Leave/Drop are bubbled by the framework drag router. Platform registration always happens at the window level.

Fluent: .AllowDrop(Boolean)