INotifyPropertyChanged in UserControl

后端 未结 3 743
[愿得一人]
[愿得一人] 2021-02-19 17:32

I have a custom control which is inherited from TextBox control. I would like to implement the INotifyPropertyChanged interface in my custom control.



        
3条回答
  •  爱一瞬间的悲伤
    2021-02-19 18:20

    the PropertyChanged event handler is alwas null.

    This will always be true until something subscribes to the PropertyChanged event.

    Typically, if you're making a custom control, however, you wouldn't use INotifyPropertyChanged. In this scenario, you'd make a Custom Dependency Property instead. Normally, the dependency objects (ie: controls) will all use Dependency Properties, and INPC is used by the classes which become the DataContext of these objects. This allows the binding system to work properly.

提交回复
热议问题