DependencyProperty 類別

定義

警告

The System.Workflow.* types are deprecated. Instead, please use the new types from System.Activities.*

一種特殊的屬性,可被定義或附加至 DependencyObject。 有三種相依性屬性:執行個體屬性、中繼屬性和附加屬性。 此類別無法獲得繼承。

public ref class DependencyProperty sealed : System::Runtime::Serialization::ISerializable
[System.Serializable]
public sealed class DependencyProperty : System.Runtime.Serialization.ISerializable
[System.Serializable]
[System.Obsolete("The System.Workflow.* types are deprecated.  Instead, please use the new types from System.Activities.*")]
public sealed class DependencyProperty : System.Runtime.Serialization.ISerializable
[<System.Serializable>]
type DependencyProperty = class
    interface ISerializable
[<System.Serializable>]
[<System.Obsolete("The System.Workflow.* types are deprecated.  Instead, please use the new types from System.Activities.*")>]
type DependencyProperty = class
    interface ISerializable
Public NotInheritable Class DependencyProperty
Implements ISerializable
繼承
DependencyProperty
屬性
實作

範例

下列範例將說明如何註冊 DependencyProperty 以供 DependencyObject 使用。 此程式碼範例是 Send Email SDK 範例的一部分,而且來自 SendMailActivity.cs 檔案。 如需詳細資訊,請參閱 傳送郵件活動

// Define the DependencyProperty objects for all of the Properties
// ...and Events exposed by this activity
public static DependencyProperty FromProperty = DependencyProperty.Register("From", typeof(string), typeof(SendEmailActivity), new PropertyMetadata("someone@example.com"));
public static DependencyProperty ToProperty = DependencyProperty.Register("To", typeof(string), typeof(SendEmailActivity), new PropertyMetadata("someone@example.com"));
' Define the DependencyProperty objects for all of the Properties 
' ...and Events exposed by me activity
Public Shared FromEmailProperty As DependencyProperty = DependencyProperty.Register("From", GetType(String), GetType(SendEmailActivity), New PropertyMetadata("someone@example.com"))
Public Shared ToProperty As DependencyProperty = DependencyProperty.Register("To", GetType(String), GetType(SendEmailActivity), New PropertyMetadata("someone@example.com"))

備註

注意

此資料討論已被汰換的類型及命名空間。 如需詳細資訊,請參閱 Windows Workflow Foundation 4.5 中即將淘汰的類型

相依性屬性支援三個使用案例。 第一,如果活動的執行個體屬性是透過使用相依性屬性實作的,則會指派給該屬性一個 ActivityBind,而非真正的值。 第二,對於為中繼資料的活動屬性 (亦即該值無法在執行階段變更),則應使用指定 Metadata 選項的相依性屬性來實作該活動屬性。 第三,相依性屬性支援附加屬性,附加屬性是動態套用到相依性物件的屬性。

屬性

DefaultMetadata
已淘汰.

取得 PropertyMetadata,它代表這個 DependencyProperty 的使用者定義資料。

IsAttached
已淘汰.

取得屬性,該屬性指出根據註冊,這個 DependencyProperty 是否與 DependencyObject 相關聯。

IsEvent
已淘汰.

取得屬性,這個屬性指出 DependencyProperty 是否是 Delegate 事件。

Name
已淘汰.

取得 NameDependencyProperty

OwnerType
已淘汰.

取得 TypeDependencyProperty

PropertyType
已淘汰.

取得儲存在 中值的 。

ValidatorType
已淘汰.

取得實作 Type 特定驗證邏輯的 DependencyProperty

方法

Equals(Object)
已淘汰.

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
FromName(String, Type)
已淘汰.

取得根據 DependencyPropertyName 註冊的 OwnerType

FromType(Type)
已淘汰.

建立 IList 型別的 DependencyProperty,該型別屬性特定的 Type

GetHashCode()
已淘汰.

傳回這個執行個體的雜湊碼。

GetType()
已淘汰.

取得目前執行個體的 Type

(繼承來源 Object)
MemberwiseClone()
已淘汰.

建立目前 Object 的淺層複製。

(繼承來源 Object)
Register(String, Type, Type)
已淘汰.

初始化根據輸入參數將屬性參數化之 DependencyProperty 類別的新執行個體。

Register(String, Type, Type, PropertyMetadata)
已淘汰.

初始化根據輸入參數將屬性參數化之 DependencyProperty 類別的新執行個體。

RegisterAttached(String, Type, Type)
已淘汰.

初始化根據輸入參數將屬性參數化之 DependencyProperty 類別的新執行個體。 這個執行個體會宣告在不是擁有型別的物件上使用的屬性。

RegisterAttached(String, Type, Type, PropertyMetadata)
已淘汰.

初始化根據輸入參數將屬性參數化之 DependencyProperty 類別的新執行個體。

RegisterAttached(String, Type, Type, PropertyMetadata, Type)
已淘汰.

初始化根據輸入參數將屬性參數化之 DependencyProperty 類別的新執行個體。

ToString()
已淘汰.

覆寫 Object 方法以傳回 Name 屬性值。

明確介面實作

ISerializable.GetObjectData(SerializationInfo, StreamingContext)
已淘汰.

將序列化目標物件的所需資料填入 SerializationInfo

適用於