Social Icons

Wednesday, 14 August 2013

INotifyPropertyChanged Interface in WPF with Example


In this article i will explain how to Create INotifyPropertyChanged Interface in Class file, How to Implement it for Binding in wpf.

Download SourceCode


         INotifyPropertyChanged Interface defined in System.ComponentModel Class. It has an event Handler called PropertyChangedEventHandler which can be used to create an Event that can be used to notify the changes occured in Properties.

For example i had a class called MobileStore with Four Properties i.e Brand, Mode, Stock, Price. We can implement INotifyPropertyChanged interface for that class as follows.

Using INotifyPropertyChanged in Binding :

      In WPF Binding Target must be Dependency Property and Source can be Dependency Property or an CLR object or other. Here Dependency Property has built-in Notification feature. So if the Source is an CLR Object or other then we need take care about changes notification to target. In that case we have to use INotifyPropertyChanged Interface to notify the bindings that source property is changed you need to update the UI with new data.

Here is an Example using Above MobileShop class and its properties. The four Properties of MobileShop class are bind to textboxes.

XAML Code:


              I hope you got simple knowledge about How to implement INotifyPropertyChanged Interface for a Class and How to use it wpf binding.

          Don't forget to Comment and Share if you like this post for our friends. Thank You.

1 comment:

Please Give your Valuable Suggestions,Questions and Comments to improve my blog.