Simple WPF Binding not working

前端 未结 1 1540
抹茶落季
抹茶落季 2021-01-20 02:53

I\'m learning WPF, and I\'m stuck with Data Bindings. I have a TreeView, which ItemSource is set to a ObserveableCollection.

相关标签:
1条回答
  • 2021-01-20 02:58

    You can only bind to public properties, you have a public field. Your code should be:

    public class UIBrowserItem 
    {
        private String title = "Test";
        public string Title
        {
           get { return title; }
           set { title = value; }
    }
    

    If the title can change at run time, you also need to implement INotifyPropertyChanged.

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