Multiple user controls share collection dependency property

后端 未结 1 2026
迷失自我
迷失自我 2021-02-13 14:49

I have implemented my own usercontrol based on listboxes. It has a dependency property with type of a collection. It works fine when I have only one instance of the usercontrol

相关标签:
1条回答
  • 2021-02-13 15:07

    Found the answer, the constructor needs to initialize the property instead of letting the static property do itself:

    public SimpleList()
    {
       SetValue(NumbersProperty, new List<int>()); 
    
       InitializeComponent();
    }
    

    Collection-Type Dependency Properties

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