1 private void InitData()
2 {
3 Staff staff = new Staff()
4 {
5 Name = "1-off",
6 Status = Status.off
7 };
8 StaffTreeItem staffTreeItem = new StaffTreeItem(staff);
9 this.treeView1.Items.Add(staffTreeItem);
10
11 staff = new Staff()
12 {
13 Name = "1-on",
14 Status = Status.on
15 };
16 staffTreeItem = new StaffTreeItem(staff);
17 this.treeView1.Items.Add(staffTreeItem);
18
19 staff = new Staff()
20 {
21 Name = "1-away",
22 Status = Status.away
23 };
24 staffTreeItem = new StaffTreeItem(staff);
25 this.treeView1.Items.Add(staffTreeItem);
26
27 }
1 public enum Status
2 {
3 on = 0,
4 away = 1,
5 off = 2
6 }
- public partial class StaffTreeItem : TreeViewItem
- {
- //public Staff staff;
- public Staff staff
- {
- get { return (Staff)GetValue(staffProperty); }
- set { SetValue(staffProperty, value); }
- }
- public static readonly DependencyProperty staffProperty =
- DependencyProperty.Register("staff", typeof(Staff), typeof(StaffTreeItem), new UIPropertyMetadata(null));
- public StaffTreeItem(Staff staff)
- {
- InitializeComponent();
- this.staff = staff;
- this.Header = staff.Name;
- this.DataContext = staff;
- this.Tag = staff;
- }
- }