wpf 实现DataGrid的表格嵌套
创始人
2025-01-10 06:04:18
0次
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; using NavTest.Eneities; using NavTest.Service.Ioc; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Windows.Controls; using System.Windows.Media;  namespace NavTest.ViewModels {     public partial class Page5ViewModel : ObservableObject, ISingleton     {         private readonly PLCModels pLCModelsIoc;          public Page5ViewModel(PLCModels pLCModelsIoc)         {             this.pLCModelsIoc = pLCModelsIoc;             this.PLCModels = pLCModelsIoc.pLCModels;             MyBrush = new SolidColorBrush(Colors.Red);              for (int i = 0; i < 50; i++)             {                 MyStudents.Add(                     new()                     {                         Id = i,                         Age = $"{i + 10}",                         Name = $"Name{i + 5}",                         MyCourse = new()                         {                             new Course()                             {                                 CourseName = "语文",                                 Teacher = "张老师",                                 Score = i + 60,                                 Classroom = $"教室{i}"                             },                             new Course()                             {                                 CourseName = "英语",                                 Teacher = "李老师",                                 Score = i + 61,                                 Classroom = $"教室{i}"                             }                             ,                             new Course()                             {                                 CourseName = "数学",                                 Teacher = "张老师",                                 Score = i + 60,                                 Classroom = $"教室{i}"                             }                             ,                             new Course()                             {                                 CourseName = "语文",                                 Teacher = "张老师",                                 Score = i + 60,                                 Classroom = $"教室{i}"                             }                             ,                             new Course()                             {                                 CourseName = "语文",                                 Teacher = "张老师",                                 Score = i + 60,                                 Classroom = $"教室{i}"                             }                         }                     }                 );             }         }          [ObservableProperty]         private ObservableCollection pLCModels;          [ObservableProperty]         private Brush myBrush;          [ObservableProperty]         private List myStudents = new();          [ObservableProperty]         private int detailInex;          [RelayCommand]         public void Detail(DataGrid dataGrid)          {             DataGridRow dataGridRow = (DataGridRow)dataGrid.ItemContainerGenerator.ContainerFromIndex(DetailInex);             if (dataGridRow.DetailsVisibility == System.Windows.Visibility.Visible)             {                 dataGridRow.DetailsVisibility = System.Windows.Visibility.Collapsed;             }             else             {                 dataGridRow.DetailsVisibility = System.Windows.Visibility.Visible;             }         }     } }  
    public class Student     {         public int Id { get; set; }         public string? Name { get; set; }         public string? Description { get; set; }         public string? Age { get; set; }         public List? MyCourse { get; set; }     } 
    public class Course     {         public string? CourseName { get; set; }         public string? Teacher { get; set; }         public int? Score { get; set; }         public string? Classroom { get; set; }     } 

效果:

在这里插入图片描述

相关内容

热门资讯

开挂方法!随便跑得快辅助透视插... 开挂方法!随便跑得快辅助透视插件,河落杠次确实有外挂,一直新版有挂一、随便跑得快可以开透视的定义与意...
开挂攻略!今日花牌辅助透视插件... 开挂攻略!今日花牌辅助透视插件,众乐是真的有外挂,原来有挂攻略一、今日花牌可以开透视的定义与意义1、...
开挂器!牵手跑胡子辅助透视插件... 开挂器!牵手跑胡子辅助透视插件,常州麻将存在有外挂,总是有挂助手1、牵手跑胡子透视辅助软件激活码多个...
开挂技巧!九天大厅辅助透视插件... 开挂技巧!九天大厅辅助透视插件,江淮竞技棋牌是有外挂,总是详细教程所有人都在同一条线上,像星星一样排...
开挂插件!38手游辅助透视插件... 开挂插件!38手游辅助透视插件,荔枝竞技真的有外挂,真是真的有挂1、金币登录送、破产送、升级送、活动...
开挂脚本!夏天YY辅助透视插件... 开挂脚本!夏天YY辅助透视插件,旺旺南平麻将是真的有外挂,好像有挂方式1、在旺旺南平麻将插件功能辅助...
开挂脚本!亲朋扯旋辅助透视插件... 开挂脚本!亲朋扯旋辅助透视插件,杭州麻将存在有外挂,切实有挂存在1、超多福利:超高返利,海量正版游戏...
开挂器!新利发辅助透视插件,指... 开挂器!新利发辅助透视插件,指尖四川麻将真的有外挂,确实详细教程1、下载好四川麻将透视辅助下载之后点...
开挂方法!斗娱斗地主辅助透视插... 开挂方法!斗娱斗地主辅助透视插件,BMW真的有外挂,切实有挂教程1、用户打开应用后不用登录就可以直接...
开挂器!朱雀大厅辅助透视插件,... 开挂器!朱雀大厅辅助透视插件,乐喜确实有外挂,本来有挂神器1、许多玩家不知道朱雀大厅辅助怎么退出观战...