O'Reilly logo

Data-Driven Services with Silverlight 2 by John Papa

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

XAML’s Binding Markup Extensions

One of the main pieces of functionality that dependency properties offer is their ability to be data-bound. In XAML, the data binding works through a specific markup extension syntax. Alternatively, you can establish the binding through .NET code. Both ways are effective and will be demonstrated in this chapter.

A set of XAML attributes exists to support the data-binding features. The following pseudocode examples represent basic usage of these extensions:

<someFrameworkElement property="{Binding}" .../>

<someFrameworkElement property="{Binding pathvalue}" .../>

<someFrameworkElement property="{Binding Path=pathvalue}" .../>

<someFrameworkElement
    property="{Binding oneOrMoreBindingProperties}" .../>

<someFrameworkElement property
    ="{Binding pathvalue, oneOrMoreBindingProperties}" .../>

In the preceding code, the element must be a FrameworkElement (thus, the name someFrameworkElement). You would replace property with the name of the property that will be the target of the binding. For example, the element might be a TextBox and the property might be Text. To bind the value of the property to a source, you can use the binding markup extensions.

The Binding attribute indicates that the value for the dependency property will come from a data-binding operation. The binding gets its source from the DataContext for the element. If the element does not have a DataContext, the XAML hierarchy is examined to see whether any parent XAML container element has a ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required