0 out of 9 rated this helpful - Rate this topic

How to create a data binding for Windows Phone

April 14, 2014

Applies to: Windows Phone 8 and Windows Phone Silverlight 8.1 | Windows Phone OS 7.1

A binding is a relationship between a UI property and a CLR object. There are several ways to create a binding object that defines a specific instance of a binding.

To create a binding in XAML

  1. Define the source object.

  2. Create a reference to the namespace of the source object in XAML.

  3. Create an instance of the source object in the Resources section.

  4. Bind to the source object by setting either the Source property or the DataContext property. The DataContext is inherited by all the element's children.

    -or-

To create a binding by using code

  1. Add the System.Windows.Data namespace

  2. Define the source object.

  3. Create the FrameworkElement you want to bind to.

  4. Create an instance of the source object

  5. Create a binding object.

  6. Set the binding properties on the binding object.

  7. Set the source of the binding by setting either the Source property or the DataContext property. The DataContext is inherited by all the element's children.

    -or-

  8. Attach the binding to the property of the FrameworkElement.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.