FrameworkElement.SetResourceReference(DependencyProperty, Object) 方法

定义

搜索具有指定名称的资源,并且为指定的属性设置一个指向该资源的资源引用。Searches for a resource with the specified name and sets up a resource reference to it for the specified property.

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

参数

dp
DependencyProperty

资源绑定到的属性。The property to which the resource is bound.

name
Object

资源的名称。The name of the resource.

注解

资源引用类似于在标记中使用DynamicResource 标记扩展A resource reference is similar to the use of a DynamicResource Markup Extension in markup. 资源引用创建一个在运行时延迟时提供指定属性值的内部表达式。The resource reference creates an internal expression that supplies the value of the specified property on a run-time deferred basis. 每当资源字典通过内部事件指示已更改的值时,或者当重定当前元素的父级(父项更改将更改字典查找路径)时,将重新计算表达式。The expression will be re-evaluated whenever the resource dictionary indicates a changed value through internal events, or whenever the current element is reparented (a parent change would change the dictionary lookup path).

适用于

另请参阅