Data Binding

Most business applications deal extensively with data. As a developer, you have a constant need to expose data in a user interface.

You can do that in a brute-force fashion by writing a lot of code to move data between user interface elements and data containers. However, such code is repetitious, bug-prone, tedious to write, and difficult to maintain.

Recognizing the problems with that approach, user interface technologies often offer an alternative called data binding, which automates much of the process of moving data into user interface elements. You're probably familiar with data binding from such earlier user interface technologies.

XAML includes a data binding subsystem, and it's one of the most advanced and powerful of any user interface technology stack. If you have been skeptical of data binding in other technologies, you should put that doubt aside and fully embrace data binding in XAML. It's a necessity for developing anything more than trivial programs.

Data Binding: Fundamental Concepts

At its most fundamental, data binding is an association between a property on one object and a property on a different object. The value in one of the properties is used to automatically update the value in the other property.

Suppose a data object of type Book had a property named Title. You can set up a binding in XAML so that the value in that property was automatically moved into the Text property of a TextBox named TitleTextBox.

To get some terminology straight, in ...

Get Professional Visual Basic 2012 and .NET 4.5 Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.