DependencyObject.GetValue(DependencyProperty) DependencyObject.GetValue(DependencyProperty) DependencyObject.GetValue(DependencyProperty) DependencyObject.GetValue(DependencyProperty) Method


DependencyObject 的此实例返回依赖属性的当前有效值。Returns the current effective value of a dependency property on this instance of a DependencyObject.

 System::Object ^ GetValue(System::Windows::DependencyProperty ^ dp);
public object GetValue (System.Windows.DependencyProperty dp);
member this.GetValue : System.Windows.DependencyProperty -> obj
Public Function GetValue (dp As DependencyProperty) As Object


DependencyProperty DependencyProperty DependencyProperty DependencyProperty

要为其检索值的属性的 DependencyProperty 标识符。The DependencyProperty identifier of the property to retrieve the value for.


返回当前的有效值。Returns the current effective value.


指定的 dp 或其值无效,或者指定的 dp 不存在。The specified dp or its value was invalid, or the specified dp does not exist.


有效值是由属性系统返回到正在请求值的任何调用方的属性的值。The effective value is the value of the property that is returned by the property system to any caller that is requesting the value. 有效的值为具有评估参与属性系统值优先级中的所有可能的输入属性系统的结果。The effective value is the result of the property system having evaluated all the possible inputs that participate in the property system value precedence. 这包括强制转换和动画。This includes coercion and animation. 有关详细信息,请参阅依赖属性值优先级For more information, see Dependency Property Value Precedence.

此方法将永远不会返回UnsetValueThis method will never return UnsetValue. UnsetValue是用在通过强制回调内部,有时也公开的各种功能的属性系统的 sentinel 值。The UnsetValue is a sentinel value for the property system that is used in various capacities internally and occasionally also exposed through coercion callbacks.

如果不确定属性的类型应该是什么,您可以查询请求的依赖关系属性,以确定是否存在多个特定的标识符PropertyType的返回值可以转换为。If you are not sure what the property's type should be, you can query the identifier of the requested dependency property to determine whether there is a more specific PropertyType that the return value can be converted to.