码迷,mamicode.com
首页 > 其他好文 > 详细

person

时间:2016-03-13 23:55:22      阅读:190      评论:0      收藏:0      [点我收藏+]

标签:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using WpfApplication1.Annotations;
 
namespace WpfApplication1
{
    class Person : INotifyPropertyChanged
    {
        private string _firstName;
 
        public string FirstName
        {
            get { return _firstName; }
            set
            {
                if (_firstName != value)
                {
                    _firstName = value;
                    FullName = $"{_firstName} {_lastName}";
                    OnPropertyChanged();
                }
            }
        }
        private string _lastName;
 
        public string LastName
        {
            get { return _lastName; }
            set
            {
                if (_lastName != value)
                {
                    _lastName = value;
                    FullName = $"{_firstName} {_lastName}";
                    OnPropertyChanged();
                }
            }
        }
 
        private string _fullName;
 
        public string FullName
        {
            get { return _fullName; }
            set
            {
                if (_fullName != value)
                {
                    _fullName = value; 
                    OnPropertyChanged();
                }
            }
        }
 
 
 
        public event PropertyChangedEventHandler PropertyChanged;
 
        [NotifyPropertyChangedInvocator]
        protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
        {
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
        }
    }
}

person

标签:

原文地址:http://www.cnblogs.com/dereklovecc/p/5274218.html

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