标签:pre 结果 lis app ext 数据绑定 创建 ring for
先创建后台实体类
1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using System.Threading.Tasks; 6 using System.Windows.Controls; 7 8 namespace WpfApp4.ViewModels 9 { 10 public class LoginModel 11 { 12 public string Name { get; set; } 13 public string Message { get; set; } 14 15 public LoginModel() 16 { 17 Name = "绑定的后台类"; 18 Message = "消息对象"; 19 Students = new List<Student>(); 20 for (int i = 0; i < 10; i++) 21 { 22 var stu = new Student() { Id = i, Name = $"{nameof(Student) + i.ToString()}", CheckBox = new CheckBox() { IsChecked = true } }; 23 Students.Add(stu); 24 } 25 } 26 27 public List<Student> Students { get; set; } 28 } 29 30 public class TestModel 31 { 32 public string Name { get; set; } 33 public string Message { get; set; } 34 35 public TestModel() 36 { 37 Name = "绑定的测试类"; 38 Message = "消息对象"; 39 } 40 } 41 42 public class Student 43 { 44 public string Name { get; set; } 45 public int Id { get; set; } 46 public CheckBox CheckBox { get; set; } 47 } 48 }
XAML引用命名空间
控件的数据绑定
运行结果
绑定LISTBOX控件
标签:pre 结果 lis app ext 数据绑定 创建 ring for
原文地址:https://www.cnblogs.com/AtTheMoment/p/14615934.html