zoukankan      html  css  js  c++  java
  • WPF 实现INotifyPropertyChanged .Net Framework 4.5

      自己动手写了一个基类来实现INotifyPropertyChanged接口,以后可以直接使用。

           

     1 using System.ComponentModel;
     2 using System.Runtime.CompilerServices;
     3 
     4 public abstract class NotifyPropertyBase: INotifyPropertyChanged
     5 {
     6      public event PropertyChangedEventHandler PropertyChenged;
     7 
     8      protected void SetProperty<T>(ref T storage, T value, [CallerMemberName] string propertyName = null)
     9      {
    10           if (object.Equals(storage, value)) return;
    11           storage = value;
    12           this.OnPropertyChanged(propertyName);
    13      }
    14 
    15      protected void OnPropertyChanged([CallerMemberName] string propertyName = null)
    16     {
    17         if (this.PropertyChanged != null)
    18             {
    19                    this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
    20              }
    21     }
    22 }
  • 相关阅读:
    tty & pty & pts
    PageRank
    How to run a terminal inside of vim?
    vimdiff
    svn's tree conflict
    svn's diff command
    符号表分离
    gcc -D
    Options for Debugging Your Program or GCC
    invoking gdb
  • 原文地址:https://www.cnblogs.com/Johar/p/8289405.html
Copyright © 2011-2022 走看看