Windows Dev Center

Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

DependencyObject::SetValue Method (DependencyProperty, Object)

Sets the local value of a dependency property, specified by its dependency property identifier.

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

public:
void SetValue(
	DependencyProperty^ dp, 
	Object^ value
)

Parameters

dp
Type: System.Windows::DependencyProperty

The identifier of the dependency property to set.

value
Type: System::Object

The new local value.

ExceptionCondition
InvalidOperationException

Attempted to modify a read-only dependency property, or a property on a sealed DependencyObject.

ArgumentException

value was not the correct type as registered for the dp property.

If the provided type does not match the type that is declared for the dependency property as it was originally registered, an exception is thrown. The value parameter should always be provided as the appropriate type.

The exception conditions are potentially influenced by the ValidateValueCallback callback that exists on the dependency property identifier of the dependency property being set. Otherwise, the value provided might be failing general type-checking conditions (for example, passing a string when the native type is Double).

.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