Tôi có BaseClass này:Thừa kế từ một baseclass thực hiện INotifyPropertyChanged?
public class BaseViewModel : INotifyPropertyChanged
{
protected void OnPropertyChanged(string propertyName)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
public event PropertyChangedEventHandler PropertyChanged;
}
và một lớp khác:
public class SchemaDifferenceViewModel : BaseViewModel
{
private string firstSchemaToCompare;
public string FirstSchemaToCompare
{
get { return firstSchemaToCompare; }
set
{
firstSchemaToCompare = value;
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs("FirstSchemaToCompare"));
//StartCommand.RaiseCanExecuteChanged();
}
}
}
PropertyChanged là ở đây (2Times), đỏ gạch chân, nó nói:
Error 1 The event BaseViewModel.PropertyChanged' can only appear on the left hand side of += or -= (except when used from within the type 'SchemaDifferenceFinder.ViewModel.BaseViewModel')
Những gì tôi làm sai? Tôi chỉ quét các PropertyChangedEvent đến một lớp học mới: BaseViewModel ..
Liên kết được chuyển lại: http://george.softumus.com/inotifypropertychanged-and-magic-strings/ –