标签:
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));
}
}
}
标签:
原文地址:http://www.cnblogs.com/dereklovecc/p/5274218.html