Data binding is the most common development technique in Wpf,silverlight and Windows Phone application development, and data binding is one of the development features in the XAML based Windows Store application development, and this article discusses Windows 8 Application development data binding use.
Fast understanding of data binding (Binding)
For application developers, whether the application interface or the application logic is often to simplify the user's operation of the data layer, it is most straightforward to implement the data synchronization update through the application control. But in the actual project development, the complex data structure and the tedious data operation make the application control and the data interaction difficulty increase, to this Microsoft launches the data binding implementation application control to synchronize the update data directly. Simple understanding of data binding, creating an object instance bound to the specified control, through DataContext dependencies, and automatically refreshing the application control data information when the object instance data changes.
Data binding Code
Data binding Basic code format:
<textbox text= "{Binding LastName, mode=twoway}"/>
The above code implements the Text property of the bound data member LastName to the TextBox, where LastName is the data member property.
Before you implement data binding, you first need to create a bound data object property, for example,
public class person
{public
string FirstName {get; set;}
public string LastName {get; set;}
public string Email {get; set;}
}
Then, when the application runs, create a data member instance,
private void Loadaccount ()
{this
. DataContext = new Person {FirstName =
"Kevin", LastName = "Fan", Email =
"qq34506@hotmail.com"};
}
This allows you to achieve simple binding effects: