How to create a data binding for Windows Phone
[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]
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
Define the source object.
Create a reference to the namespace of the source object in XAML.
Create an instance of the source object in the Resources section.
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
Add the System.Windows.Data namespace
Define the source object.
Create the FrameworkElement you want to bind to.
Create an instance of the source object
Create a binding object.
Set the binding properties on the binding object.
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-
Attach the binding to the property of the FrameworkElement.