Search code examples
wpfdependency-propertiesoperator-precedence

Dependency property precedence. I want local value to be overridable


I am writing a custom control. It has a dependency property that is supplied a "default" value by the control. This value can change 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?


Solution

  • 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.