码迷,mamicode.com
首页 > Windows程序 > 详细

MVVM WPF 简化 类的开发

时间:2020-05-14 12:58:35      阅读:76      评论:0      收藏:0      [点我收藏+]

标签:logs   hang   this   http   cal   blog   arch   string   www   

https://www.cnblogs.com/li-peng/p/3169864.html

 

https://www.cnblogs.com/ColdJokeLife/archive/2013/05/30/3108112.html

 

//C#5.0 版本
public abstract class ObservableObject : INotifyPropertyChanged
 {
        public event PropertyChangedEventHandler PropertyChanged;
protected void SetProperty<T>(ref T field, T value, [CallerMemberName] string propertyName = null)
        {
            if (EqualityComparer<T>.Default.Equals(field, value))
            {
                return;
            }

            field = value;
            var handler = this.PropertyChanged;
            if (handler != null)
            {
                handler(this, new PropertyChangedEventArgs(propertyName));
            }
        }
}

 

public class Person : NotifyPropertyChangedEx
{
    private string name;

    public string Name
    {
       get { return name; }
       set { this.SetProperty(ref name, value); }
    }

MVVM WPF 简化 类的开发

标签:logs   hang   this   http   cal   blog   arch   string   www   

原文地址:https://www.cnblogs.com/DotNet1010/p/12887226.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!