Thursday, May 3, 2012

INotifyPropertyChanged – VB.NET Simple Way

Binding, making the UI data get sync/updated with the data is the most time taking coding area.  This aspect got simplified with the Two Way Binding in WPF or any .Net program.

It is easy to implement a INotifyPropertyChanged in VB program by doing these 3 lines of code where 2 lines at at class level and 1 at object level and not to forget “Imports System.ComponentModel”

Code Lines are:

Public Class SampleClass
        Implements INotifyPropertyChanged

Public Event PropertyChanged As PropertyChangedEventHandler Implements INotifyPropertyChanged.PropertyChanged

RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(“Propety Name”))

Example follows:

image

Clear image can be found at http://clip2net.com/s/1Sn4b

Edit:  The INotifyPropertyChanged is for a class or structure, in other terms, it is used to notify (raise event) to whom ever listening or using the property that the value is changed and do the needful as accordingly.

5 comments:

  1. The I Notify Property Changed interface is used to notify clients, typically binding clients, that a property value has changed.

    ReplyDelete
  2. Thanks alot, I've been trying to understand this for a while now.

    ReplyDelete

  3. Keep up the good work.Looking forward to your work. Thank you for sharing your beautiful thoughts.We at Property Hunters shifted this service to a level much higher than the broker concept. If you are willing to buy property in Qatar please visit us. you can see more details like this article Apartments for sale in Doha Qatar

    ReplyDelete
  4. This is such a great resource that you are providing and you give it away for free. I love seeing blog that understand the value. Im glad to have found this post as its such an interesting one! I am always on the lookout for quality posts and articles so i suppose im lucky to have found this! I hope you will be adding more in the future... view

    ReplyDelete