I am writing a custom control. It has a dependency property that is supplied a "default" value by the control. This value can 开发者_如何学Cchange at any time.
I want to be able to override this value via a style or whatever, but the dependency property precedence imposed by WPF means that my local default value always wins.
Is there any way of deferring to other sources when writing a control?
You could trying clearing the local value via DependencyObject.ClearValue()
. I don't think you can change the order of precedence for dependency properties.
I think I've found a way around it.
I now expose two properties. A "Default" one that the control updates, and a standard one. In my default control style I bind the standard one to the default one so it gets the values, but can still be bound to something else in the xaml.
精彩评论