Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
RegisterAttached Method (String, Type, Type)

DependencyProperty.RegisterAttached Method (String, Type, Type)

Registers an attached property with the specified property name, property type, and owner type.

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

'Declaration
Public Shared Function RegisterAttached ( _
	name As String, _
	propertyType As Type, _
	ownerType As Type _
) As DependencyProperty

Parameters

name
Type: System.String

The name of the dependency property to register.

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.

An attached property is a property concept defined by Extensible Application Markup Language (XAML). WPF implements attached properties as dependency properties. Because the WPF attached properties are dependency properties, they can have metadata applied that can be used by the general property system for operations such as reporting layout characteristics. For more information, see Attached Properties Overview.

For more information on dependency property registration, see DependencyProperty.

The following example registers an attached property on an abstract class using this RegisterAttached signature.

Public Shared ReadOnly IsBubbleSourceProperty As DependencyProperty = DependencyProperty.RegisterAttached("IsBubbleSource", GetType(Boolean), GetType(AquariumObject2))
Public Shared Sub SetIsBubbleSource(ByVal element As UIElement, ByVal value As Boolean)
    element.SetValue(IsBubbleSourceProperty, value)
End Sub
Public Shared Function GetIsBubbleSource(ByVal element As UIElement) As Boolean
    Return CType(element.GetValue(IsBubbleSourceProperty), Boolean)
End Function

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Show:
© 2015 Microsoft