Created
March 20, 2012 09:35
-
-
Save ielcoro/2133417 to your computer and use it in GitHub Desktop.
Uso de la nueva funcionalidad Method Caller Information para implementar INotifyPropertyChanged
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class EntidadBase: INotifyPropertyChanged | |
{ | |
protected void Set<T>(ref T campo, T valor, [CallerMemberName] string propiedad= "") | |
{ | |
if (!Object.Equals(campo, valor)) | |
{ | |
campo= valor; | |
OnPropertyChanged(propiedad); | |
} | |
} | |
//Implementación de INotifyPropertyChanged | |
} | |
public class Persona: EntidadBase | |
{ | |
private string nombre; | |
public string Nombre | |
{ | |
get { return nombre; } | |
set { Set(ref nombre, value); } // El compilador llena automaticamente el nombre de la propiedad | |
} | |
private int edad; | |
public int Edad | |
{ | |
get { return edad; } | |
set { Set(ref edad, value); } // El compilador llena automaticamente el nombre de la propiedad | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment