ContentElement.AllowDrop 属性

定义

获取或设置一个值,该值指示此元素能否用作拖放操作的目标。Gets or sets a value that indicates whether this element can be used as the target of a drag-and-drop operation.

public:
 property bool AllowDrop { bool get(); void set(bool value); };
public bool AllowDrop { get; set; }
member this.AllowDrop : bool with get, set
Public Property AllowDrop As Boolean

属性值

Boolean

如果此元素可用作拖放操作的目标,则为 true;否则为 falsetrue if this element can be used as the target of a drag-and-drop operation; otherwise, false. 默认值为 falseThe default value is false.

示例

下面的示例 AllowDrop 在中设置 XAMLXAMLThe following example sets AllowDrop in XAMLXAML.

<Paragraph Name="focusableP" Style="{StaticResource FocusableParagraph}"  AllowDrop="True" Drop="dropHandler">
  Drop something here...
  <Hyperlink Name="h1" Click="MakeSpecialLink">Follow me!</Hyperlink>
</Paragraph>

注解

默认情况下不启用拖放操作,并且必须通过将设置 AllowDrop 为来特意启用 trueDrag-and-drop operations are not enabled by default, and must be enabled deliberately by setting AllowDrop to true. 除了此基本设置外,拖放行为完全是特定实现的,并且不是由 ContentElement 或任何其他基元素类定义的。Beyond this basic setting, drag-and-drop behavior is entirely implementation specific and is not defined by ContentElement or any other base element class. 某些控件(例如) RichTextBox 具有默认行为,但没有 ContentElement 派生类具有这样的行为。Certain controls, for example, RichTextBox, do have a default behavior, but no ContentElement derived classes have such a behavior. 有关拖放的详细信息,请参阅 拖放概述For more information on drag and drop, see Drag and Drop Overview.

FrameworkContentElement 在其实现中重写此依赖项属性的元数据。FrameworkContentElement overrides the metadata for this dependency property in its implementation. 具体而言, FrameworkContentElement 指定此属性允许 Inherits true 在元数据) (的属性值继承。Specifically, FrameworkContentElement designates that this property allows property value inheritance (Inherits is true in metadata). 此上下文中的属性值继承表示,如果有子元素没有任何其他值可 AllowDrop 通过本地值或样式进行分配,则使用此值指定的最接近的父元素的值 (再次,无论是在样式、默认值或本地值) 中,该父元素的值被属性系统分配给所有未分配的子元素。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 that parent element is assigned to all unassigned child elements by the property system. 这意味着,你可以指定是否在根元素处允许放置操作,然后将该值传播到所有 FrameworkContentElement 未向其分配值的子元素 falseThis means that you can specify whether to allow drop operations at the root element and then propagate the value to all FrameworkContentElement child elements that have not specifically assigned it a value of false.

依赖项属性信息Dependency Property Information

标识符字段Identifier field AllowDropProperty
元数据属性设置为 trueMetadata properties set to true None

适用于