'IDataErrorInfo' is a 'namespace' but is used like a 'type' - WPF
I try use IDataErrorInfo in WPF app on validation data, but if I try implement interface IDataErrorInfo in my class, I get this error:
'IDataErrorInfo' is a 'namespace' but is used like a 'type' I using namespace System.ComponentModel. Any advance.
code is here:
public partial class MainWindow : Window
{
public class Friend : IDataErrorInfo
{
private string _id;
public string ID
{
get { return _id; }
set { _id = value; }
}
private string _lastError;
public string Error
{
get { return _lastError; }
}
string IDataErrorInfo.this[string propertyName]
{
get
{
开发者_JS百科 switch (propertyName)
{
case "ID": if (String.IsNullOrEmpty(ID))
_lastError = "Please insert a name!";
break;
default: _lastError = string.Empty;
break;
}
return _lastError;
}
}
}
public MainWindow()
{
InitializeComponent();
}
}
}
Because it is a namespace You may be importing a wrong DLL
Try to use Ctrl + Space in IDataErrorInfo. It is a namespace. Or it might be the same name with your namespace that it gets confused. In your import statement, you can try to rename your imported namespace: using Error = System.ComponentModel; (for example)
Try this explanation: http://msdn.microsoft.com/en-us/library/system.componentmodel.idataerrorinfo.aspx
Have a look at the Framework section What is your OS? It said it does not support Windows 8, and stuff. Maybe try to use another library, or change your OS, or wait until your OS supports it.
Thank you,
精彩评论