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

效果:

在这里插入图片描述

相关内容

热门资讯

两分钟透视“红龙poker透视... 两分钟透视“红龙poker透视挂指令”约局吧德州透视(必备开挂透视辅助app)红龙poker透视挂指...
盘点一款!禅游指尖四川辅助脚本... 盘点一款!禅游指尖四川辅助脚本(透视)AI教程(新版作弊开挂辅助安装);禅游指尖四川辅助脚本最新版本...
一分钟了解!潘潘讲故事app有... 一分钟了解!潘潘讲故事app有挂(辅助挂)扑克教程(规律作弊开挂辅助软件);详细潘潘讲故事app有挂...
八分钟透视“wepoker破解... 八分钟透视“wepoker破解器激活码”wepoker有挂(了解开挂透视辅助神器)1、实时wepok...
专业讨论!aapoker真的假... 专业讨论!aapoker真的假的(透视)必胜教程(2026作弊开挂辅助工具);是一款可以让一直输的玩...
第3分钟透视“黑侠破解wepo... 第3分钟透视“黑侠破解wepoker”hhpoker透视方法(新版开挂透视辅助app);1、hhpo...
记者揭秘!werplan免费挂... 记者揭秘!werplan免费挂下载(辅助挂)wepoke教程(第三方作弊开挂辅助插件)是一款可以让一...
第5分钟透视“wepoker俱... 第5分钟透视“wepoker俱乐部辅助”wepoker私人局透视教程(科普开挂透视辅助工具);1、完...
一分钟了解!非凡贪玩技巧(辅助... 您好,非凡贪玩技巧这款游戏可以开挂的,确实是有挂的,需要了解加微【136704302】很多玩家在这款...
六分钟透视“aapoker破解... 六分钟透视“aapoker破解侠是真的”wpk透视挂是真的(专业开挂透视辅助工具)1、用户打开应用后...