Monday, January 23, 2012

INotifyPropertyChanged for the VB Control Creating Guy

Visual Studio Magazine - Integrating with the .NET Framework UI Controls

"The .NET Framework team obviously assumes you'll build your applications and the classes that make up your application a certain way. If you leverage those assumptions you'll get lots of cool benefits (and, if you don't leverage those benefits…well, you'll get to do a lot more work).

For instance, the user interface controls you can drag onto your WPF or Silverlight forms (TextBoxes, DropDownList, and so on) assume that you'll bind class properties to them. Those controls look for specific features in your classes; if you build those features into your code, you'll get a lot of functionality for free. The benefit is that you can build those objects independent of your UI, which supports automated testing, parallel development and loose coupling between application components.

One example of how you can integrate your classes with a XAML UI is the INotifyPropertyChanged interface. Adding this interface (and some code) to your classes gives you some almost magical benefits. For instance, if you have an object whose property is bound to and displayed in some user interface control, the control will automatically update in your user interface if you update the property from code. There's no need to do anything to make the user interface display the property's latest value: you don't need to update the control or call a Refresh method on the control (or the form).

Adding the INotifyPropertyChanged interface to your class is easy:

...

SNAGHTMLa65018c..."

Good to see VB get a little love. I also like the re-use message... (i.e. how components let you DRY, help the S in SOILD, etc)

No comments:

Post a Comment

NOTE: Anonymous Commenting has been turned off for a while... The comment spammers are just killing me...

ALL comments are moderated. I will review every comment before it will appear on the blog.

Your comment WILL NOT APPEAR UNTIL I approve it. This may take some hours...

I reserve, and will use, the right to not approve ANY comment for ANY reason. I will not usually, but if it's off topic, spam (or even close to spam-like), inflammatory, mean, etc, etc, well... then...

Please see my comment policy for more information if you are interested.

Thanks,
Greg

PS. I am proactively moderating comments. Your comment WILL NOT APPEAR UNTIL I approve it. This may take some hours...