Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

DependencyProperty.Register Method (String, Type, Type)

Registers a dependency property with the specified property name, property type, and owner type.

Namespace:  System.Windows
Assembly:  WindowsBase (in WindowsBase.dll)

public static DependencyProperty Register(
	string name,
	Type propertyType,
	Type ownerType
)
You cannot use methods in XAML.

Parameters

name
Type: System.String

The name of the dependency property to register. The name must be unique within the registration namespace of the owner type.

propertyType
Type: System.Type

The type of the property.

ownerType
Type: System.Type

The owner type that is registering the dependency property.

Return Value

Type: System.Windows.DependencyProperty
A dependency property identifier that should be used to set the value of a public static readonly field in your class. That identifier is then used to reference the dependency property later, for operations such as setting its value programmatically or obtaining metadata.

For more information on dependency property registration, see DependencyProperty.

public static readonly DependencyProperty IsDirtyProperty = DependencyProperty.Register(
  "IsDirty",
  typeof(Boolean),
  typeof(AquariumObject3)
);

More Code

How to: Implement a Dependency Property This example shows how to back a common language runtime (CLR) property with a DependencyProperty field, thus defining a dependency property. When you define your own properties and want them to support many aspects of Windows Presentation Foundation (WPF) functionality, including styles, data binding, inheritance, animation, and default values, you should implement them as a dependency property.

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0

Community Additions

ADD
Show:
© 2015 Microsoft