WPF: How can I find the source of an inherited property value

本秂侑毒 提交于 2019-12-08 03:49:38

问题


I've been working on a WPF-project that has a certain nick that I can't seem to grasp: there are a couple of controls that include other controls and are styled by a Style-definition in a Resource Dictionary. One of the inner controls is a Label. That Label has an inherited Padding of 5.

The Label has no styling defined, let alone any padding. And it's indicated to be inherited, but I can't find where that Padding is coming from. So, my question is: how can I figure out where this value is inherited from?


回答1:


As Michiel M said DependencyPropertyHelper.GetValueSource is the way to go.

There is a distinct order of evaluation where the value can originate:

Most important is on top

  1. Forced Value by Property System (CoerceValueCallback)
  2. Animation
  3. Locally set value
  4. Style trigger
  5. Template trigger
  6. Style setter
  7. Theme style trigger
  8. Theme style setter
  9. Inheritance
  10. Default value

Finally ValidateValueCallback accepts or discards the value if set

This probably helps



来源:https://stackoverflow.com/questions/17722269/wpf-how-can-i-find-the-source-of-an-inherited-property-value

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!