Esta documentación está archivada y no tiene mantenimiento.

DependencyProperty.RegisterAttached (Método) (String, Type, Type, PropertyMetadata)

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

Espacio de nombres: System.Windows
Ensamblado: WindowsBase (en windowsbase.dll)

public static DependencyProperty RegisterAttached (
	string name,
	Type propertyType,
	Type ownerType,
	PropertyMetadata defaultMetadata
public static DependencyProperty RegisterAttached (
	String name, 
	Type propertyType, 
	Type ownerType, 
	PropertyMetadata defaultMetadata
public static function RegisterAttached (
	name : String, 
	propertyType : Type, 
	ownerType : Type, 
	defaultMetadata : PropertyMetadata
) : DependencyProperty
No se pueden utilizar métodos en XAML.



The name of the dependency property to register.


The type of the property.


The owner type that is registering the dependency property.


Property metadata for the dependency property. This can include the default value as well as other characteristics.

Valor devuelto

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, but that aspect is not a strict requirement to be an attached property. 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.

This example shows how to register an attached property and provide public accessors so that you can use the property in both Extensible Application Markup Language (XAML) and code. Attached properties are a syntax concept defined by Extensible Application Markup Language (XAML). Most attached properties for WPF types are also implemented as dependency properties. You can use dependency properties on any DependencyObject types.

The following example shows how to register an attached property as a dependency property, by using the RegisterAttached method. The provider class has the option of providing default metadata for the property that is applicable when the property is used on another class, unless that class overrides the metadata. In this example, the default value of the IsBubbleSource property is set to false.

The provider class for an attached property (even if it is not registered as a dependency property) must provide static get and set accessors that follow the naming convention Set[AttachedPropertyName] and Get[AttachedPropertyName]. These accessors are required so that the acting XAML reader can recognize the property as an attribute in XAML and resolve the appropriate types.

public static readonly DependencyProperty IsBubbleSourceProperty = DependencyProperty.RegisterAttached(
  new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender)
public static void SetIsBubbleSource(UIElement element, Boolean value)
  element.SetValue(IsBubbleSourceProperty, value);
public static Boolean GetIsBubbleSource(UIElement element)
  return (Boolean)element.GetValue(IsBubbleSourceProperty);

Microsoft .NET Framework 3.0 es compatible con Windows Vista, Microsoft Windows XP SP2 y Windows Server 2003 SP1.

.NET Framework

Compatible con: 3.0