private static string _data = "";
public static string _Data
{
get
{
return _data;
}
set
{
_data = value;
NotifyOfPropertyChange(() => _Data);
}
}
最佳答案
您可以创建自己的引发StaticPropertyChanged
事件的方法:
private static string _data = "";
public static string _Data
{
get
{
return _data;
}
set
{
_data = value;
NotifyStaticPropertyChanged(nameof(_Data));
}
}
public static event EventHandler<PropertyChangedEventArgs> StaticPropertyChanged;
private static void NotifyStaticPropertyChanged(string propertyName)
{
if (StaticPropertyChanged != null)
StaticPropertyChanged(null, new PropertyChangedEventArgs(propertyName));
}
请引用以下博客文章以获取更多信息:http://10rem.net/blog/2011/11/29/wpf-45-binding-and-change-notification-for-static-properties
关于c# - 如何在静态属性中使用NotifyOfPropertyChange(Caliburn Micro),我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/49943227/