Skip to content

Instantly share code, notes, and snippets.

@JohanLarsson
Created February 26, 2014 00:08
Show Gist options
  • Save JohanLarsson/9220700 to your computer and use it in GitHub Desktop.
Save JohanLarsson/9220700 to your computer and use it in GitHub Desktop.
public class Machine : INotifyPropertyChanged
{
private Tool _tool;
public event PropertyChangedEventHandler PropertyChanged;
public event EventHandler<ToolChangedEventArgs> ToolChanged;
public Tool Tool
{
get { return _tool; }
set
{
if (Equals(value, _tool))
{
return;
}
_tool = value;
OnPropertyChanged();
}
}
protected virtual void OnToolChanged(ToolChangedEventArgs e)
{
var handler = ToolChanged;
if (handler != null)
{
handler(this, e);
}
}
[NotifyPropertyChangedInvocator]
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
var handler = PropertyChanged;
if (handler != null)
{
handler(this, new PropertyChangedEventArgs(propertyName));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment