DependencyObject.SetValue Method (DependencyProperty, Object)
Sets the local value of a dependency property, specified by its dependency property identifier.
Assembly: WindowsBase (in WindowsBase.dll)
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).