implement INotifyPropertyChanged
Published: 9. October 2011 | Updated: 9. October 2011License: Microsoft Public License (MS-PL)
Categories: Implementations
Tags: C# Design Patterns
Import namespace
using System.ComponentModel;
Code
public class MyClass : INotifyPropertyChanged { private int _value; // property that uses interface public int Value { get { return _value; } set { if (value != _value) // check if value is not same { _value = value; OnPropertyChanged("Value"); // invoke event } } } // interface member public event PropertyChangedEventHandler PropertyChanged; // invocation of event private void OnPropertyChanged(string propertyName) { if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); } }
| Send us feedback about this snippet » |





