Share via


UIElement.AllowDrop Property

Definition

Gets or sets a value that determines whether this UIElement can be a drop target for purposes of drag-and-drop operations.

public:
 property bool AllowDrop { bool get(); void set(bool value); };
bool AllowDrop();

void AllowDrop(bool value);
public bool AllowDrop { get; set; }
var boolean = uIElement.allowDrop;
uIElement.allowDrop = boolean;
Public Property AllowDrop As Boolean
<uiElement AllowDrop="bool"/>

Property Value

Boolean

bool

true if this UIElement can be a drop target for purposes of drag-and-drop operations; otherwise, false. The default is false.

Remarks

The value of AllowDrop determines whether various events related to being a drop target or responding to being dragged over can be handled. Such events only can be handled if AllowDrop is true on the UIElement that is a potential drop target. These events are:

Each of the listed events is a routed event. If you want to handle a bubbling drag-drop event, the potential drop target must have AllowDrop set to true, and the object where the event is handled must have AllowDrop set to true. For more info on routed event concepts, see Events and routed events overview.

The Windows Runtime implementation of drag-drop concepts permits only certain controls and input actions to initiate a drag-drop action. There is no generalized DoDragDrop method that would permit any UI element to initiate a drag-drop action. The main source of a drag-drop action in an app is when you drag the items of a list such as GridView. However once the action is initiated, any UIElement in the app can potentially be a drop target so long as AllowDrop is true on that element. Any elements that the drag-drop action passes over can handle DragEnter, DragLeave or DragOver. The initiating list view does not require AllowDrop. Instead, the value of CanDragItems is used to determine whether the items in the list can be used to start a drag-drop action.

A UI element can't be a drop target for any drag-drop action that begins from outside the current app. This includes actions that come from another app, which is possible for a snapped view.

Applies to

See also