当绑定数据源的某属性值改变时,它可以通知客户端,并进行界面数据更新.而我们不用写很多复杂的代码来更新界面数据,这样可以做到方法简洁而清晰,INotifyPropertyChanged确实是一个强大的接口
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
private People p;
int i=1;
public Form1()
{
p = new People();
p.Age = 1;
InitializeComponent();
this.labAge.Text = p.Age.ToString();
}
private void button1_Click(object sender, EventArgs e)
{
p.Age = i++;
this.labAge.Text = p.Age.ToString();
}
}
public class People:INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
private int age;
public int