-
Notifications
You must be signed in to change notification settings - Fork 1k
/
Copy pathMyDataContext.cs
99 lines (92 loc) · 2.85 KB
/
MyDataContext.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
using System;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
namespace CustomColumn
{
public class MyDataContext
{
ObservableCollection<MyObject> view;
public ObservableCollection<MyObject> View
{
get
{
if (view == null)
{
view = new ObservableCollection<MyObject>(from i in Enumerable.Range(0, 100) select
new MyObject()
{
ID = i,
Name = string.Format("Name{0}", i),
IsExpandable = i < 50,
IsExpanded = i < 50 && i % 3 == 0
});
}
return view;
}
}
}
public class MyObject : INotifyPropertyChanged
{
private int id;
public int ID
{
get { return id; }
set
{
if (id != value)
{
id = value;
this.OnPropertyChanged("ID");
}
}
}
private string name;
public string Name
{
get { return name; }
set
{
if (name != value)
{
name = value;
this.OnPropertyChanged("Name");
}
}
}
private bool isExpandable;
public bool IsExpandable
{
get { return isExpandable; }
set
{
if (isExpandable != value)
{
isExpandable = value;
this.OnPropertyChanged("IsExpandable");
}
}
}
private bool isExpanded;
public bool IsExpanded
{
get { return isExpanded; }
set
{
if (isExpanded != value)
{
isExpanded = value;
this.OnPropertyChanged("IsExpanded");
}
}
}
private void OnPropertyChanged(string propertyName)
{
if (this.PropertyChanged != null)
{
this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
public event PropertyChangedEventHandler PropertyChanged;
}
}