It is clear to me why dependency property are static and the question still remain on my mind is why we need to use Readonly keyword at the time of declaration of Dependency Pro
Conceptually a dependency property is something that a dependency object simply has and that does not depend on when you use the property. Just like a CLR property, if you ask does this object have a Total
property, you know it cannot be a double
now but an int
later. As a result, we'd make the dependency property const
if we could, but we cannot, so readonly
is the next best thing.
Using the readonly
keyword has at least three effects: