PostSharpAPI ReferencePost­Sharp.​Patterns.​XamlDependency­Property­AttributeDefault­Value
Open sandboxFocus

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.

public object DefaultValue { get; set; }
Property Value
Type Description

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).