DependencyObject.SetCurrentValue(DependencyProperty, Object) Method

Definition

设置依赖属性的值而不更改其值源。Sets the value of a dependency property without changing its value source.

public:
 void SetCurrentValue(System::Windows::DependencyProperty ^ dp, System::Object ^ value);
public void SetCurrentValue (System.Windows.DependencyProperty dp, object value);
member this.SetCurrentValue : System.Windows.DependencyProperty * obj -> unit
Public Sub SetCurrentValue (dp As DependencyProperty, value As Object)

Parameters

dp
DependencyProperty

要设置的依赖属性的标识符。The identifier of the dependency property to set.

value
Object

新的本地值。The new local value.

Exceptions

尝试修改只读依赖属性或密封 DependencyObject 上的属性。Attempted to modify a read-only dependency property, or a property on a sealed DependencyObject.

value 不是为 dp 属性注册的正确类型。value was not the correct type as registered for the dp property.

Remarks

此方法由组件使用,该组件以编程方式设置其自己的属性之一的值,而无需禁用应用程序声明的属性用法。This method is used by a component that programmatically sets the value of one of its own properties without disabling an application's declared use of the property. SetCurrentValue 方法可更改属性的有效值,但现有触发器、数据绑定和样式将继续工作。The SetCurrentValue method changes the effective value of the property, but existing triggers, data bindings, and styles will continue to work.

Applies to