优化更新
This commit is contained in:
160
WPFUIAPP/ViewModel.cs
Normal file
160
WPFUIAPP/ViewModel.cs
Normal file
@@ -0,0 +1,160 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
|
||||
namespace WPFUIAPP
|
||||
{
|
||||
public partial class ViewModel : ObservableObject
|
||||
{
|
||||
[ObservableProperty]
|
||||
private ObservableCollection<Staff> staffList = [];
|
||||
|
||||
public ViewModel()
|
||||
{
|
||||
InitNode1Value();
|
||||
}
|
||||
public void InitNode1Value()
|
||||
{
|
||||
Staff staff = new Staff()
|
||||
{
|
||||
Name = "Alice",
|
||||
Age = 30,
|
||||
Sex = "Male",
|
||||
Duty = "Manager",
|
||||
IsExpanded = true
|
||||
};
|
||||
Staff staff2 = new Staff()
|
||||
{
|
||||
Name = "Alice1",
|
||||
Age = 21,
|
||||
Sex = "Male",
|
||||
Duty = "Normal",
|
||||
IsExpanded = true
|
||||
};
|
||||
Staff staff3 = new Staff()
|
||||
{
|
||||
Name = "Alice11",
|
||||
Age = 21,
|
||||
Sex = "Male",
|
||||
Duty = "Normal"
|
||||
};
|
||||
staff2.StaffList.Add(staff3);
|
||||
staff3 = new Staff()
|
||||
{
|
||||
Name = "Alice22",
|
||||
Age = 21,
|
||||
Sex = "Female",
|
||||
Duty = "Normal"
|
||||
};
|
||||
staff2.StaffList.Add(staff3);
|
||||
staff.StaffList.Add(staff2);
|
||||
staff2 = new Staff()
|
||||
{
|
||||
Name = "Alice2",
|
||||
Age = 22,
|
||||
Sex = "Female",
|
||||
Duty = "Normal"
|
||||
};
|
||||
staff.StaffList.Add(staff2);
|
||||
staff2 = new Staff()
|
||||
{
|
||||
Name = "Alice3",
|
||||
Age = 23,
|
||||
Sex = "Female",
|
||||
Duty = "Normal"
|
||||
};
|
||||
staff.StaffList.Add(staff2);
|
||||
StaffList.Add(staff);
|
||||
|
||||
staff = new Staff()
|
||||
{
|
||||
Name = "Bob",
|
||||
Age = 31,
|
||||
Sex = "Male",
|
||||
Duty = "CEO"
|
||||
};
|
||||
staff2 = new Staff()
|
||||
{
|
||||
Name = "Bob1",
|
||||
Age = 24,
|
||||
Sex = "Female",
|
||||
Duty = "Normal"
|
||||
};
|
||||
staff.StaffList.Add(staff2);
|
||||
staff2 = new Staff()
|
||||
{
|
||||
Name = "Bob2",
|
||||
Age = 25,
|
||||
Sex = "Female",
|
||||
Duty = "Normal"
|
||||
};
|
||||
staff.StaffList.Add(staff2);
|
||||
staff2 = new Staff()
|
||||
{
|
||||
Name = "Bob3",
|
||||
Age = 26,
|
||||
Sex = "Male",
|
||||
Duty = "Normal"
|
||||
};
|
||||
staff.StaffList.Add(staff2);
|
||||
StaffList.Add(staff);
|
||||
|
||||
staff = new Staff()
|
||||
{
|
||||
Name = "Cyber",
|
||||
Age = 32,
|
||||
Sex = "Female",
|
||||
Duty = "Leader"
|
||||
};
|
||||
staff2 = new Staff()
|
||||
{
|
||||
Name = "Cyber1",
|
||||
Age = 27,
|
||||
Sex = "Female",
|
||||
Duty = "Normal"
|
||||
};
|
||||
staff.StaffList.Add(staff2);
|
||||
staff2 = new Staff()
|
||||
{
|
||||
Name = "Cyber2",
|
||||
Age = 28,
|
||||
Sex = "Female",
|
||||
Duty = "Normal"
|
||||
};
|
||||
staff.StaffList.Add(staff2);
|
||||
StaffList.Add(staff);
|
||||
}
|
||||
}
|
||||
|
||||
public partial class Staff : ObservableObject
|
||||
{
|
||||
[ObservableProperty]
|
||||
private string? name = null;
|
||||
|
||||
[ObservableProperty]
|
||||
private int age;
|
||||
|
||||
[ObservableProperty]
|
||||
private string? sex = null;
|
||||
|
||||
[ObservableProperty]
|
||||
private string? duty = null;
|
||||
|
||||
[ObservableProperty]
|
||||
private bool isChecked = true;
|
||||
|
||||
[ObservableProperty]
|
||||
private bool isSelected = false;
|
||||
|
||||
[ObservableProperty]
|
||||
private bool isExpanded = false;
|
||||
|
||||
[ObservableProperty]
|
||||
private ObservableCollection<Staff> staffList = [];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user