How can I change the default value of an inherited dependency property?

前端 未结 1 856
栀梦
栀梦 2020-12-03 04:50

How can I change the default value for an inherited dependency property? In our case, we\'ve created a subclass of Control which by default has its Focusable s

相关标签:
1条回答
  • 2020-12-03 05:17

    The correct way to override a base class's property is:

    static TestControl() {
    
        FooProperty.OverrideMetadata(
            typeof(TestControl),
            new FrameworkPropertyMetadata(67)
        );
    }
    

    EDIT:

    AddOwner is meant to share the same DependencyProperty across types that are not related (i.e. the TextProperty of TextBox and TextBlock).

    0 讨论(0)
提交回复
热议问题