nuget安装Faker
用法:
新建一个model
public class Model { public string Name { get; set; } public int Age { get; set; } }
使用Faker给Model赋值
private void Button_Click(object sender, RoutedEventArgs e) { List<Model> list = new List<Model>(); for (int i = 0; i < 100; i++) { list.Add(new Model() { Name = Faker.NameFaker.Name(), Age = Faker.NumberFaker.Number() }); } grid.ItemsSource = list; }
效果: