private string balance;
public string Balance
{
get { return balance; }
set
{
if (balance != value)
{
balance = value;
RaisePropertyChangedEvent(() => Balance); //这一句
}
}
}
//以下的代码
public event PropertyChangedEventHandler PropertyChanged = (sender, e) => { };
private void RaisePropertyChangedEvent<T>(Expression<Func<T>> propertyExpression)
{
PropertyChanged(this, new PropertyChangedEventArgs(GetPropertyName(propertyExpression)));
}
private string GetPropertyName<T>(Expression<Func<T>> propertyExpression)
{
var expression = propertyExpression.Body as System.Linq.Expressions.MemberExpression;
return expression.Member.Name;
}
最上面的是属性,下面这一大段是什么?起什么作用?
缥缈止盈
沧海一幻觉