DependencyProperty.Register 方法

定义

创建具有特定初始化条件的 DependencyProperty 的新实例。

重载

Register(String, Type, Type)

初始化 DependencyProperty 类的新实例,它根据输入参数将属性参数化。

Register(String, Type, Type, PropertyMetadata)

初始化 DependencyProperty 类的新实例,它根据输入参数将属性参数化。

Register(String, Type, Type)

初始化 DependencyProperty 类的新实例,它根据输入参数将属性参数化。

public:
 static System::Workflow::ComponentModel::DependencyProperty ^ Register(System::String ^ name, Type ^ propertyType, Type ^ ownerType);
public static System.Workflow.ComponentModel.DependencyProperty Register (string name, Type propertyType, Type ownerType);
static member Register : string * Type * Type -> System.Workflow.ComponentModel.DependencyProperty
Public Shared Function Register (name As String, propertyType As Type, ownerType As Type) As DependencyProperty

参数

name
String

DependencyProperty 的名称。

propertyType
Type

属性可以包含的值的 Type

ownerType
Type

依赖属性的所有者 Type

返回

根据输入参数将属性参数化的 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"))

适用于

Register(String, Type, Type, PropertyMetadata)

初始化 DependencyProperty 类的新实例,它根据输入参数将属性参数化。

public:
 static System::Workflow::ComponentModel::DependencyProperty ^ Register(System::String ^ name, Type ^ propertyType, Type ^ ownerType, System::Workflow::ComponentModel::PropertyMetadata ^ defaultMetadata);
public static System.Workflow.ComponentModel.DependencyProperty Register (string name, Type propertyType, Type ownerType, System.Workflow.ComponentModel.PropertyMetadata defaultMetadata);
static member Register : string * Type * Type * System.Workflow.ComponentModel.PropertyMetadata -> System.Workflow.ComponentModel.DependencyProperty
Public Shared Function Register (name As String, propertyType As Type, ownerType As Type, defaultMetadata As PropertyMetadata) As DependencyProperty

参数

name
String

DependencyProperty 的名称。

propertyType
Type

属性可以包含的值的 Type

ownerType
Type

依赖属性的所有者 Type

defaultMetadata
PropertyMetadata

附加属性选项。

返回

根据输入参数将属性参数化的 DependencyProperty 类。

适用于