月更
This commit is contained in:
63
AntdWpfDemo/ViewModels/DataGridViewModel.cs
Normal file
63
AntdWpfDemo/ViewModels/DataGridViewModel.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.Composition;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
using Caliburn.Micro;
|
||||
|
||||
namespace AntdWpfDemo.ViewModels
|
||||
{
|
||||
[Export(typeof(IScreen))]
|
||||
class DataGridViewModel : Screen
|
||||
{
|
||||
private ObservableCollection<TestDataModel> _testData;
|
||||
public ObservableCollection<TestDataModel> TestData
|
||||
{
|
||||
get => _testData;
|
||||
set
|
||||
{
|
||||
_testData = value;
|
||||
NotifyOfPropertyChange(() => TestData);
|
||||
}
|
||||
}
|
||||
|
||||
public DataGridViewModel()
|
||||
{
|
||||
DisplayName = "DataGrid";
|
||||
InitializeTestData();
|
||||
}
|
||||
|
||||
private void InitializeTestData()
|
||||
{
|
||||
var random = new Random();
|
||||
TestData = new ObservableCollection<TestDataModel>();
|
||||
|
||||
string[] names = { "张三", "李四", "王五", "赵六", "钱七" };
|
||||
string[] addresses = { "北京市海淀区", "上海市浦东新区", "广州市天河区", "深圳市南山区", "杭州市西湖区" };
|
||||
|
||||
for (int i = 1; i <= 20; i++)
|
||||
{
|
||||
TestData.Add(new TestDataModel
|
||||
{
|
||||
Id = i,
|
||||
Name = names[random.Next(names.Length)],
|
||||
Age = random.Next(18, 60),
|
||||
Address = addresses[random.Next(addresses.Length)],
|
||||
CreateTime = DateTime.Now.AddDays(-random.Next(1, 365))
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class TestDataModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public int Age { get; set; }
|
||||
public string Address { get; set; }
|
||||
public DateTime CreateTime { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user