使用INotifyPropertyChanged的静态属性。 C#

我正在尝试创建一个静态属性,其中INotifyPropertyChanged将更新对我绑定的DataGrid ComboBox所做的任何更改。

我收到此错误,

错误CS0026关键字’this’在静态属性,静态方法或静态字段中无效

通过我的搜索,我发现了为什么你不能在.Net的静态方法中使用关键字’this’? ,但即使经历了一切,我仍然无法弄清楚如何让这个工作。

但是,我改变的任何东西只会否定我试图用INotifyPropertyChanged制作一个静态属性???

我的代码:

 private static List _nursingHomeSectionListProperty; public static List NursingHomeSectionListProperty { get { return _nursingHomeSectionListProperty; } set { _nursingHomeSectionListProperty = value; NotifyStaticPropertyChanged(); } } 

而Property改变了处理程序

 public static event PropertyChangedEventHandler StaticPropertyChanged; public static void NotifyStaticPropertyChanged([CallerMemberName] string propertyName = null) { StaticPropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); } 

以下代码是我如何使用属性更改处理程序的非静态属性,

 public event PropertyChangedEventHandler PropertyChanged; public void NotifyPropertyChanged([CallerMemberName] string propertyName = null) { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); } 

只需传递null而不是:

 public static event PropertyChangedEventHandler StaticPropertyChanged; private static void NotifyStaticPropertyChanged([CallerMemberName] string name = null) { StaticPropertyChanged?.Invoke(null, new PropertyChangedEventArgs(name)); } 

有关静态属性更改通知的详细信息,请参阅此博客文章