C#WPF basic steps for data binding

Source: Internet
Author: User

Basic steps for data binding:

(1) First declare a class and its attributes

(2) Initialize class assignment

(3) Datacontext= the control object in C # code;

(4) In the interface design, the control gives the properties of the property {Binding class}

Principle: Listen to the event mechanism, interface changes such as TextChanged events, so change the interface can be modified to the object

To enable the normal object to implement data binding, the INotifyPropertyChanged interface needs to be implemented to listen for properchanged. The specific code is shown below:

Class person:inotifypropertychanged

{

private int age;

public int Age

{

Get

{

return age;

}

Set

{

This.age = value;

if (propertychanged! = null)

{

PropertyChanged (This,

New PropertyChangedEventArgs ("Age"));

}

}

}

}

C#WPF basic steps for data binding

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.