Source Code

The source code is available on CodePlex.

The library is licensed under the LGPL.

Web development just got a little bit lighter

Update Controls is data binding without INotifyPropertyChanged. You never have to implement it. And you never have to consume it. And now it works with Silverlight 3.

Just like with the Winforms and WPF versions, Update Controls Light requires you to identify independent properties. An independent property is one that can be changed. It's value does not depend upon anything else. For example, a Customer's name is independent, as well as their list of invoices. You indicate that these properties are independent by creating an Independent sentry and calling OnGet() and OnSet() whenever they are accessed or changed.

Public Class Customer
    Dim _name As String
    Dim _invoices As List(Of Invoice)

    Dim _indName As New Independent
    Dim _indInvoices As New Independent

    Public Property Name() As String
        Get
            _indName.OnGet()
            Return _name
        End Get
        Set(ByVal value As String)
            _indName.OnSet()
            _name = value
        End Set
    End Property

    Public ReadOnly Property Invoices() As IEnumerable(Of Invoice)
        Get
            _indInvoices.OnGet()
            Return _invoices
        End Get
    End Property

    Public Function NewInvoice(ByVal number As String) As Invoice
        _indInvoices.OnSet()
        Dim invoice As New Invoice(number)
        _invoices.Add(invoice)
        Return invoice
    End Function
End Class

Then just before you assign your View Model to the DataContext, wrap it for the View.

DataContext = ForView.Wrap( _
    New PaymentViewModel(payment, _
        New PaymentNavigationModel))

Properties in the View Model that use independent properties are dependent upon them. Update Controls recognizes those dependencies and fires PropertyChanged events for you.

Think about that. It isn't just firing PropertyChanged for the properties that you indicate as Independent. It's firing PropertyChanged for all the properties that use those properties.

Two lists

Here's an example. This control has two lists: paid invoices and unpaid invoices.

Get Microsoft Silverlight

In a typical program, you would handle the "Paid" and "Unpaid" buttons by removing selected invoices from one list and adding them to the other. But with Update Controls Light, you just change the data model. The two lists are dependent.

Public ReadOnly Property PaidInvoices() As IEnumerable(Of Invoice)
    Get
        Return _payment.PaidInvoices
    End Get
End Property

Public ReadOnly Property UnpaidInvoices() As IEnumerable(Of Invoice)
    Get
        Return _payment.Customer.Invoices.Except(_payment.PaidInvoices)
    End Get
End Property

The body of the UnpaidInvoices property tells the whole story. When you add an invoice to the payment, it no longer appears in UnpaidInvoices. Update Controls Light can see this and fire the right notification events.

Update Controls makes Silverlight data binding a breeze.