Windows 8 Instance Tutorial: Data binding Base instance

Source: Internet
Author: User

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:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.