Este artículo se tradujo de forma manual. Mueva el puntero sobre las frases del artículo para ver el texto original. |
Traducción
Original
|
INotifyPropertyChanged.PropertyChanged (Evento)
.NET Framework 4
Se produce cuando cambia el valor de una propiedad.
Ensamblado: System (en System.dll)
El evento PropertyChanged puede indicar que todas las propiedades del objeto han cambiado utilizando Nothing o String.Empty como el nombre de propiedad en PropertyChangedEventArgs.
En el ejemplo de código siguiente se muestra cómo implementar el evento PropertyChanged de la interfaz INotifyPropertyChanged.
// This is a simple customer class that // implements the IPropertyChange interface. public class DemoCustomer : INotifyPropertyChanged { // These fields hold the values for the public properties. private Guid idValue = Guid.NewGuid(); private string customerNameValue = String.Empty; private string phoneNumberValue = String.Empty; public event PropertyChangedEventHandler PropertyChanged; private void NotifyPropertyChanged(String info) { if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs(info)); } } // The constructor is private to enforce the factory pattern. private DemoCustomer() { customerNameValue = "Customer"; phoneNumberValue = "(555)555-5555"; } // This is the public factory method. public static DemoCustomer CreateNewCustomer() { return new DemoCustomer(); } // This property represents an ID, suitable // for use as a primary key in a database. public Guid ID { get { return this.idValue; } } public string CustomerName { get { return this.customerNameValue; } set { if (value != this.customerNameValue) { this.customerNameValue = value; NotifyPropertyChanged("CustomerName"); } } } public string PhoneNumber { get { return this.phoneNumberValue; } set { if (value != this.phoneNumberValue) { this.phoneNumberValue = value; NotifyPropertyChanged("PhoneNumber"); } } } }
Windows 7, Windows Vista SP1 o posterior, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (no se admite Server Core), Windows Server 2008 R2 (se admite Server Core con SP1 o posterior), Windows Server 2003 SP2
.NET Framework no admite todas las versiones de todas las plataformas. Para obtener una lista de las versiones compatibles, vea Requisitos de sistema de .NET Framework.
Contenido de la comunidad
Agregar
