ContentElement.AllowDrop ContentElement.AllowDrop ContentElement.AllowDrop ContentElement.AllowDrop Property

定義

取得或設定值,這個值表示此項目是否可以用來做為拖放作業的目標。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

屬性值

如果這個項目可以作為拖放作業的目標,則為 true;否則為 falsetrue if this element can be used as the target of a drag-and-drop operation; otherwise, false. 預設值為 falseThe default value is false.

範例

下列範例會設定AllowDropXAMLXAMLThe 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>

備註

拖放作業不會預設啟用,且必須藉由設定刻意啟用AllowDroptrueDrag-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指定這個屬性可讓屬性值繼承 (Inheritstrue中繼資料中)。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

適用於