Skip to content

Instantly share code, notes, and snippets.

@JayBazuzi
Last active March 10, 2017 21:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JayBazuzi/ae5bd627269cb00ceaa9f9c3d3294dea to your computer and use it in GitHub Desktop.
Save JayBazuzi/ae5bd627269cb00ceaa9f9c3d3294dea to your computer and use it in GitHub Desktop.
public class MyViewModel : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged = delegate {};
string _name;
public string Name
{
get { return _name; }
set
{
if (_name == value) return
_name = value;
PropertyChanged(this, new PropertyChangedEventArgs("Name"));
}
}
}
public class MyViewModel : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged = delegate {};
string _name;
public string Name
{
get { return _name; }
set
{
if (_name == value) return
_name = value;
RaiseNotifyPropertyChanged();
}
}
void RaiseNotifyPropertyChanged([CallerMemberName]string propertyName = null)
{
PropertyChanged(this, new PropertyChangedEventArgs("Name"));
}
}
public class MyViewModel : NotifyPropertyChanged
{
string _name;
public string Name
{
get { return _name; }
set
{
if (_name == value) return
_name = value;
RaiseNotifyPropertyChanged();
}
}
}
// This is utility code that you could share with the world.
abstract class NotifyPropertyChanged : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged = delegate {};
void RaiseNotifyPropertyChanged([CallerMemberName]string propertyName = null)
{
PropertyChanged(this, new PropertyChangedEventArgs("Name"));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment