Last active
August 29, 2015 14:25
-
-
Save Fhernd/4f55e5ee8a60b403307a to your computer and use it in GitHub Desktop.
Demostración de de uso de la interfaz 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
// OrtizOL - xCSw - http://ortizol.blogspot.com | |
using System; | |
using System.ComponentModel; | |
using System.Runtime.CompilerServices; | |
public class UsoINotifyPropertyChanged : INotifyPropertyChanged | |
{ | |
public event PropertyChangedEventHandler PropertyChanged = delegate{}; | |
public void InvocarAlCambioPropiedad([CallerMemberName] string nombrePropiedad = null) | |
{ | |
PropertyChanged(this, new PropertyChangedEventArgs(nombrePropiedad)); | |
Console.WriteLine(nombrePropiedad); | |
} | |
string nombreCliente; | |
public String NombreCliente | |
{ | |
get | |
{ | |
return nombreCliente; | |
} | |
set | |
{ | |
if (value == nombreCliente) return; | |
nombreCliente = value; | |
InvocarAlCambioPropiedad(); // El compilador convierte esta | |
// llamada en InvocarAlCambioPropiedad("NombreCliente"); | |
} | |
} | |
int idClient; | |
public int IDCliente | |
{ | |
get | |
{ | |
return idClient; | |
} | |
set | |
{ | |
if (value == idClient) return; | |
idClient = value; | |
InvocarAlCambioPropiedad(); // El compilador convierte esta | |
// llamada en InvocarAlCambioPropiedad("IDCliente"); | |
} | |
} | |
} | |
public class Prueba | |
{ | |
public static void Main() | |
{ | |
Console.WriteLine(Environment.NewLine); | |
UsoINotifyPropertyChanged var = new UsoINotifyPropertyChanged(); | |
var.NombreCliente = "Julio"; | |
var.IDCliente = 951753852; | |
Console.WriteLine(Environment.NewLine); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment