PostSharp6.6//API Reference/Post­Sharp.​Patterns.​Xaml Namespace/Dependency­Property­Attribute Class/Dependency­Property­Attribute Properties/Dependency­Property­Attribute.​Default­Value Property

DependencyPropertyAttribute.DefaultValue Property

Gets or sets the initial value of the dependency property and the DefaultValue property of the dependency property metadata. If you set this property, do not use a property initializer.

Namespace:  PostSharp.Patterns.Xaml
Assembly:  PostSharp.Patterns.Xaml (in PostSharp.Patterns.Xaml.dll) Version: 6.6.7.0 (6.6.7.0)
Syntax
C#
public Object DefaultValue { get; set; }

Property Value

Type: Object
Remarks

There are two ways to set the initial value of a dependency property when you use DependencyPropertyAttribute: You can use this property (but in that case you're limited to constants) or you can use the property initializer or set the initial value in the constructor (but in that case, the DefaultValue property will not be set).

If you set both this property and the property initializer to nonzero, nonnull values, an exception is thrown. However, you can set the metadata default value using this property and you can change the actual initial value in the constructor (not the initializer).

See Also