In yesterday’s post, I talked about MVVM and how easy it is to start building
composite applications leveraging this innovative programming paradigm. Until today, I was struggling
with linking dynamically created UI elements to the view-model. To take it one step further, I wanted
the user interface to be bound fully (Two-Way) to the view-model and be automatically updated as the
view-model changes.

What’s an example? You have a view that prompts the user to input a count. That count could be used
to create Albums, Contacts or whatever ‘class’ you want. Here’s the sample code for an Album.cs file:

Update your view code with the XAML below, link your DataContext to your view-model and as you add new Album objects to your Albums observable collection, they will automatically show up on your UI and be bound to the view-model. Yes, it’s that simple to build rich UIs that are managed by user input at runtime.