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

屬性值

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

範例

下列範例會在 XAMLXAML中設定 AllowDropThe 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 設定為 true來故意啟用。Drag-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. 這表示您可以指定是否允許在根項目上進行 drop 作業,然後將值傳播至尚未明確指派給其值為 false的所有 FrameworkContentElement 子項目。This 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
設定為 true 的中繼資料屬性Metadata properties set to true NoneNone

適用於