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

效果:

在这里插入图片描述

相关内容

热门资讯

突发!hhpoker透视脚本下... 突发!hhpoker透视脚本下载,德普之星透视辅助软件下载,一贯是真的有挂(有挂教学)德普之星透视辅...
代打辅助挂!wpk俱乐部是做什... 代打辅助挂!wpk俱乐部是做什么的,德普软件,一直存在有挂(有挂神器)德普软件辅助器是一种具有地方特...
2026版教学!pokemmo... 2026版教学!pokemmo辅助器手机版下载,德普之星透视辅助,切实是有挂(有挂详细)1、该软件可...
教程辅助挂!wepoker插件... 教程辅助挂!wepoker插件辅助,德普之星私人局辅助器,果然真的有挂(今日头条)1、玩家可以在德普...
一直以来!cloudpoker... 一直以来!cloudpoker外挂,德扑之星透视软件免费入口官网,本来是真的有挂(竟然有挂)1、德扑...
做出回应!wepoker游戏安... 做出回应!wepoker游戏安装教程,智星菠萝透视,竟然存在有挂(的确有挂)亲,关键说明,智星菠萝透...
今日!wepoker免费辅助器... 今日!wepoker免费辅助器,德普之星app安卓版破解版,确实是有挂(有挂细节)1、很好的工具软件...
总结辅助挂!德普之星辅助工具如... 总结辅助挂!德普之星辅助工具如何打开,德扑之星怎么开辅助,一直真的有挂(证实有挂)1、下载好德普之星...
黑科技插件!hhpoker透视... 黑科技插件!hhpoker透视方法,德扑圈有透视吗,真是存在有挂(有挂总结)1、下载好德扑圈有透视吗...
第三方插件!wejoker辅助... 第三方插件!wejoker辅助软件,智星菠萝辅助,一直是真的有挂(有挂解密)1、全新机制【智星菠萝辅...