INotifyPropertyChanged in UserControl

后端 未结 3 1650
傲寒
傲寒 2021-02-19 17:36

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:07

    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.

提交回复
热议问题