Skip to content

Instantly share code, notes, and snippets.

@ElemarJR
Created April 19, 2011 14:04
Show Gist options
  • Save ElemarJR/927930 to your computer and use it in GitHub Desktop.
Save ElemarJR/927930 to your computer and use it in GitHub Desktop.
namespace SilverlightApplication1
{
public partial class MainPage : UserControl
{
public MainPage()
{
InitializeComponent();
this.Loaded += (s, e) => { this.DataContext = new Person(); };
}
}
public class Person : INotifyPropertyChanged
{
string NameField;
public string Name {
get
{
return this.NameField;
}
set
{
if (value.Length < 10) throw new Exception("Erro!");
this.NameField = value;
if (this.PropertyChanged != null)
this.PropertyChanged(this, new PropertyChangedEventArgs("Name"));
}
}
public event PropertyChangedEventHandler PropertyChanged;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment