Dependency Property optimisation?

前端 未结 1 1043
天涯浪人
天涯浪人 2021-01-24 04:56

When I set collection value from xaml within the control as such it seems to set value correctly:

 
    

        
相关标签:
1条回答
  • 2021-01-24 05:07

    The cause is that a local property value has higher precedence than a value from a Style Setter.

    Instead of setting a local value, you could use the SetCurrentValue method:

    public InjectCustomArray()
    {
        InitializeComponent();
        SetCurrentValue(MyPropertyProperty, new ICustomType[0]);
    }
    

    See the Dependency Property Value Precedence article on MSDN for more details.

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