问题
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
- Forced Value by Property System (CoerceValueCallback)
- Animation
- Locally set value
- Style trigger
- Template trigger
- Style setter
- Theme style trigger
- Theme style setter
- Inheritance
- 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