Why does OnPropertyChanged not work in Code Behind?

后端 未结 1 1180
情歌与酒
情歌与酒 2020-12-10 14:49

I\'m trying to simplify some code by putting the ViewModel models into the code behind and binding the DataContext as \"this\", but it seems to work differently, in the foll

相关标签:
1条回答
  • 2020-12-10 15:09

    You haven't marked your class as being available for property change notification. Change the heading to

    public partial class Window1 : Window, INotifyPropertyChanged
    

    Just because you implement the methods doesn't mean that WPF knows that a class supports change notification - you need to tell it by marking it with INotifyPropertyChanged. This way, the binding mechanism can identify your class as a potential update target.

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