Custom attribute that, when applied to a static automatic property of type Attached<T>,
turns this property into a XAML dependency property that has the same name and whose value type is T.
Inheritance
Implements
Namespace: PostSharp.Patterns.Xaml
Assembly: PostSharp.Patterns.Xaml.dll
Syntax
[ComVisible(false)]
[Serializer(typeof(AttachedPropertyAttribute.Serializer))]
public sealed class AttachedPropertyAttribute : DependencyPropertyBaseAttribute, ILocationLevelAspect, ILocationLevelAspectBuildSemantics, IAspectBuildSemantics, IValidableAnnotation, IAspectProvider, IAspect, IServiceRemarks
Suppose the target property is named Foo. If a method named ValidateFoo exists in the class, it will be used to validate the values assigned to this property.
If a method named OnFooChanged exists in the class, it will be invoked whenever the property is set.
If a property named FooProperty exists in the class, it will be assigned to the corresponding DependencyProperty instance.
Naming conventions can be overridden by the PostSharp.Patterns.Xaml.DependencyPropertyBaseAttribute.ValidateValueMethod, PostSharp.Patterns.Xaml.DependencyPropertyBaseAttribute.PropertyChangedMethod
and PostSharp.Patterns.Xaml.DependencyPropertyBaseAttribute.RegistrationProperty aspect properties.
The target property must be public and static. The validation method and the property-changed method must be static. The declaring class must derive from DependencyObject.
The XAML compiler requires a static SetFoo method, which PostSharp cannot generate because it runs after compilation.
Implement it by calling SetValue(DependencyObject, T).
Constructors
| Name | Description |
|---|---|
| AttachedPropertyAttribute() | |
| AttachedPropertyAttribute(PortableFormatterConstructorContext) |