开发者

Dependency property precedence. I want local value to be overridable

开发者 https://www.devze.com 2023-03-28 22:10 出处:网络
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 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消