1. 声明静态事件
///
/// 静态属性通知
///
public static event EventHandler StaticPropertyChanged;
2.静态属性 setter
private static bool _IsConnectSeccess;
///
/// 是否连接成功
///
public static bool IsConnectSeccess
{
get { return _IsConnectSeccess; }
set
{
_IsConnectSeccess = value;
StaticPropertyChanged?.Invoke(null,new PropertyChangedEventArgs(nameof(IsConnectSeccess)));
}
}
3. xmal 这里比较重要, 要加括号 不然不能正常通知 甚至编译时异常 T-T
4. 只有.net frameWork 4.5以上才有这个功能,
原文连接