DependencyPropertyHelper 类


提供一种帮助程序方法 (GetValueSource(DependencyObject, DependencyProperty)),此方法可报告依赖属性的有效值的属性系统源。Provides a single helper method (GetValueSource(DependencyObject, DependencyProperty)) that reports the property system source for the effective value of a dependency property.

public ref class DependencyPropertyHelper abstract sealed
public static class DependencyPropertyHelper
type DependencyPropertyHelper = class
Public Class DependencyPropertyHelper


WPFWPF属性系统相当复杂, 它依赖于建立的值确定优先级, 合理化可能来自各种输入的值。TheWPFWPF property system is fairly complex, and relies on rationalizing the values that potentially come from a variety of inputs, based on an established value determination precedence. 由于这些源可能来自运行时代码、已编译的标记, 甚至来自运行时用户设置, 因此, 准确了解依赖项属性值系统中的哪个参与者确定了在调用GetValue在运行时对该属性进行。Because these sources potentially come from run-time code, from compiled markup, or even from run-time user settings, it can be useful to know exactly which participant in the dependency property value system established the value you obtain when calling GetValue at run-time on that property. 如果值来自于预期之外的其他源, 可能需要调整应用程序的某个方面。If the value came from a different source than you had intended, you might need to adjust some aspect of your application. 值源可能是样式、主题、本地值、动画、绑定或基于运行时的值 (例如系统设置通过主题或系统资源)。The value source might be a style, a theme, a local value, an animation, a binding, or a run-time based value such as system settings through themes or system resources. 有关详细信息,请参阅依赖属性值优先级For more information, see Dependency Property Value Precedence.

通常情况下, 对属性进行报告的另一种机制是属性元数据, 而不是对象上的属性的特定实例。Another mechanism that reports on the property in general, rather than a specific instance of the property on an object, is the property metadata. 通过调用GetMetadata和检查返回PropertyMetadata的 (或返回的属性元数据可转换到的多个可能的派生类之一), findable 属性元数据。The property metadata is findable by calling GetMetadata and examining the returned PropertyMetadata (or one of several possible derived classes that the returned property metadata is castable to).


GetValueSource(DependencyObject, DependencyProperty)

返回一种结构,该结构报告特定 DependencyObject 上指定依赖属性的各种元数据和属性系统特征。Returns a structure that reports various metadata and property system characteristics of a specified dependency property on a particular DependencyObject.

IsTemplatedValueDynamic(DependencyObject, DependencyProperty)

指示指定元素是否属于某个模板的实例,该实例定义可在运行时根据其他位置的更改而更改的指定属性的值。Indicates whether a specified element belongs to an instance of a template that defines a value for the specified property that may change at runtime based on changes elsewhere.