我正在尝试实现Inotifypropertychange
接口,例如
public class EmployeeDetails:INotifyPropertyChanged
{
private int employeeID;
public int EmployeeID
{
get { return employeeID; }
set { employeeID = value; this.NotifyPropertyChanged("EmployeeId"); }
}
private string employeeName;
public string EmployeeName
{
get { return employeeName; }
set { employeeName = value; this.NotifyPropertyChanged("EmployeeName"); }
}
private decimal salary;
public decimal Salary
{
get { return salary; }
set { salary = value; this.NotifyPropertyChanged("Salary"); }
}
public event PropertyChangedEventHandler propertychange;
public void NotifyPropertyChanged(string name)
{
if (propertychange != null)
propertychange(this, new PropertyChangedEventArgs(name));
}
public EmployeeDetails(int employeeId, string employeeName, decimal salary)
{
EmployeeID = employeeID;
EmployeeName = employeeName;
Salary = salary;
}
public EmployeeDetails()
{
// TODO: Complete member initialization
}
}
在调试时,它显示以下错误:
'EmployeeDetails'未实现接口成员'System.ComponentModel.INotifyPropertyChange
我遗漏了哪些特定代码,请帮忙
我已经加入了system.component
汇编。
答案 0 :(得分:2)
您可以使用此代码
public class EmployeeDetails : INotifyPropertyChanged
{
...
}
右键单击INotifyPropertyChanged,首先执行resolve reference并选择实现接口