How to Implement a ListBox of Checkboxes in WPF?

后端 未结 5 1294
南笙
南笙 2021-02-05 06:23

Although somewhat experienced with writing Winforms applications, the... \"vagueness\" of WPF still eludes me in terms of best practices and design patterns.

Despite pop

5条回答
  •  暖寄归人
    2021-02-05 07:23

    Assuming TopicList is not an ObservableCollection therefore when you add items no INotifyCollection changed is being fired to tell the binding engine to update the value.

    Change your TopicList to an ObservableCollection which will resolve the current issue. You could also populate the List ahead of time and then the binding will work via OneWay; however ObservableCollection is a more robust approach.

    EDIT:

    Your TopicList needs to be a property not a member variable; bindings require properties. It does not need to be a DependencyProperty.

    EDIT 2:

    Modify your ItemTemplate as it does not need to be a HierarchicalDataTemplate

       
         
           
             
           
         
       
    

提交回复
热议问题