DependencyProperty Precedence(4)
If you want to know that where the value of DependencyProperty comes from, there is a class called DependencyPropertyHelper.
1: public static class DependencyPropertyHelper
2: {
3: // Methods
4: public static ValueSource GetValueSource(DependencyObject dependencyObject, DependencyProperty dependencyProperty);
5: }
It just has one static method called GetValueSource and the parameters is dependencyObject instance and dependencyProperty instance.
The type of return value is ValueSource:
1: public struct ValueSource
2: {
3: public BaseValueSource BaseValueSource { get; }
4: public bool IsExpression { get; }
5: public bool IsAnimated { get; }
6: public bool IsCoerced { get; }
7: }
8:
9: public enum BaseValueSource
10: {
11: Unknown,
12: Default,
13: Inherited,
14: DefaultStyle,
15: DefaultStyleTrigger,
16: Style,
17: TemplateTrigger,
18: StyleTrigger,
19: ImplicitStyleReference,
20: ParentTemplate,
21: ParentTemplateTrigger,
22: Local
23: }
It contains some read-only properties. If you have time, you can use this method to get
the ValueSource of targetButton’s Width Property(code is attached in the preview post).
And you will understand the DependencyProperty precedence better!
I have tried and find that In some scenario, IsAnimation = true and IsCoerce = true.
Comments
- Anonymous
January 06, 2009
PingBack from http://www.codedstyle.com/dependencyproperty-precedence4-2/