WPF第九章集合数据源.docVIP

  • 1
  • 0
  • 约 21页
  • 2016-09-09 发布于重庆
  • 举报
WPF第九章集合数据源

绑定到集合数据源,原则上说只需要实现IEnumerable接口的类型均可以做为集合数据源进行数据绑定,例如:定义一个学生类(StudentInfo),一个学生集合类(继承ObservableCollectionStudentInfo类),在集合类中添加若干学生的信息。 1: using System.ComponentModel; 2:? 3: namespace WPFBindingCollection 4: { 5: /// summary 6: /// 学生信息类 7: /// /summary 8: public class StudentInfo : INotifyPropertyChanged 9: { 10: private int _StudentID; 11: private string _StudentName; 12: private double _Score; 13: private string _HeaderImage; 14:? 15: public int StudentID 16: { 17: set 18: { 19: if (value != _StudentID) 20: { 21: _StudentID = value; 22: Notify(StudentID); 23: } 24: } 25: get 26: { 27: return _StudentID; 28: } 29: } 30: public string StudentName 31: { 32: set 33: { 34: if (value != _StudentName) 35: { 36: _StudentName = value; 37: Notify(StudentName); 38: } 39: } 40: get 41: { 42: return _StudentName; 43: } 44: } 45: public double Score 46: { 47: set 48: { 49: if (value != _Score) 50: { 51: _Score = value; 52: Notify(Score); 53: } 54: } 55: get 56: { 57: return _Score; 58: } 59: } 60: public string HeaderImage 61: { 62: set 63: { 64: if (value != _HeaderImage) 65: { 66: _HeaderImage = value;

文档评论(0)

1亿VIP精品文档

相关文档