C# <T>(Expression<Func<T>>
privatestringbalance;publicstringBalance{get{returnbalance;}set{if(balance!=value){ba...
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;
}
最上面的是属性,下面这一大段是什么?起什么作用? 展开
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;
}
最上面的是属性,下面这一大段是什么?起什么作用? 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询