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; }     } 

效果:

在这里插入图片描述

相关内容

热门资讯

总结辅助!购买的wpk辅助在哪... 总结辅助!购买的wpk辅助在哪里下载,德普之星辅助软件,解密教程(存在有挂)购买的wpk辅助在哪里下...
教程攻略!聚财平台辅助,小闲川... 教程攻略!聚财平台辅助,小闲川南宜宾辅助,办法教程(有挂工具)1、全新机制【小闲川南宜宾辅助ai辅助...
玩家亲测!poker worl... 玩家亲测!poker world辅助器,雀友会广东潮汕麻雀,攻略教程(有挂教学)1、全新机制【雀友会...
法门辅助!wpk控制牌是真的吗... 法门辅助!wpk控制牌是真的吗,hhpoker怎么破解,解迷教程(有挂讲解)1、起透看视 wpk控制...
查到实测辅助!情怀莆仙外挂,湖... 查到实测辅助!情怀莆仙外挂,湖北逍遥卡五星辅助,绝活儿教程(果真有挂)1、全新机制【湖北逍遥卡五星辅...
据统计!wepoker怎么设置... 据统计!wepoker怎么设置房间,hhpoker大菠萝有没有作比,模板教程(有挂技巧)1、全新机制...
模板辅助!wepoker透视a... 模板辅助!wepoker透视app下载,wepoker俱乐部辅助,曝光教程(发现有挂)1、下载好we...
教程辅助!乐乐围棋入门辅助,爱... 教程辅助!乐乐围棋入门辅助,爱来大菠萝挂,教材教程(有挂分析)1、不需要AI权限,帮助你快速的进行乐...
技术分享!werplan免费挂... 技术分享!werplan免费挂下载,天酷游戏交易平台,手筋教程(有挂方法)1、下载好天酷游戏交易平台...
法门辅助!wepoker开脚本... 法门辅助!wepoker开脚本视频,aapoker透视脚本下载,了解教程(有挂教学)aapoker透...