Este artículo se tradujo automáticamente. Para ver el artículo en inglés, active la casilla Inglés. Además, puede mostrar el texto en inglés en una ventana emergente si mueve el puntero del mouse sobre el texto.
Traducción
Inglés

Propiedad UIElement.AllowDrop

 

Obtiene o establece un valor que indica si este elemento se puede usar como destino de una operación de arrastrar y colocar. Es una propiedad de dependencia.

Espacio de nombres:   System.Windows
Ensamblado:  PresentationCore (en PresentationCore.dll)

public bool AllowDrop { get; set; }

Valor de propiedad

Type: System.Boolean

true si este elemento se puede usar como destino de una operación de arrastrar y colocar; de lo contrario, false. El valor predeterminado es false.

Drag-and-drop operations are not enabled by default, and must be enabled deliberately by setting P:System.Windows.UIElement.AllowDrop to true. Beyond this basic setting, drag-and-drop behavior is entirely implementation specific and is not defined by T:System.Windows.UIElement or any other base element class. Certain controls, for example, T:System.Windows.Controls.RichTextBox, do have a default behavior. For more information on drag and drop, see Drag and Drop Overview.

FrameworkElement overrides the metadata for this dependency property in its implementation. Specifically, FrameworkElement designates this property to allow property value inheritance (Inherits is true in metadata). Property value inheritance in this context means that if there are child elements with no other value for AllowDrop assigned through local values or styles, the value of the nearest parent element with this value assigned (again, either in styles, by default values, or a local value), then the value from the parent element will be assigned to all previously unassigned child elements by the property system. In practice this means that you can specify whether to allow drop operations at the root element, and that value will propagate to all child elements that have not specifically assigned it as false.

Identifier field

AllowDropProperty

Metadata properties set to true

None

The following markup example sets the P:System.Windows.UIElement.AllowDrop property true using an attribute on a T:System.Windows.Controls.TextBox, as well as setting some other related properties that in aggregate enable that T:System.Windows.Controls.TextBox to be the target of a multiline text data object when it is dragged in. For the complete sample, see Load a Dropped File Sample.

<TextBox
  Name="tbDisplayFileContents" 
  Grid.Row="1" 
  AcceptsReturn="True" AcceptsTab="True" 
  AllowDrop="True" 
  BorderThickness="1" BorderBrush="Black" 
  HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto"

  PreviewDragOver="ehDragOver" PreviewDrop="ehDrop"
/>

.NET Framework
Disponible desde 3.0
Silverlight
Disponible desde 4.0
Windows Phone Silverlight
Disponible desde 7.1
Volver al principio
Mostrar: