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

效果:

在这里插入图片描述

相关内容

热门资讯

此事迅速冲上热搜!约局吧开挂,... 此事迅速冲上热搜!约局吧开挂,哈糖大菠萝辅助器(透视)资料脚本(原来真的是有挂)-哔哩哔哩哈糖大菠萝...
推出新举措!掌电竞技辅助工具,... 推出新举措!掌电竞技辅助工具,新畅游互娱辅助app(透视)技巧-确实真的有挂1、用户打开应用后不用登...
透视透视挂!来几局辅助器开挂,... 透视透视挂!来几局辅助器开挂,雀友会手机透视辅助器app(开挂)好像是真的挂(有挂方法)-哔哩哔哩1...
迎来新发展!wepoker免费... 迎来新发展!wepoker免费钻石,wepoker透视是真的吗(透视)练习教程(总是有挂)wepok...
突发!xpoker辅助器,拱趴... 突发!xpoker辅助器,拱趴大菠萝怎么开挂(透视)指南脚本(竟然是真的挂)-哔哩哔哩1、任何拱趴大...
据玩家消息!衢州都莱辅助器下载... 您好,衢州都莱辅助器下载这款游戏可以开挂的,确实是有挂的,需要了解加去威信【136704302】很多...
透视脚本!微乐江苏小程序游戏破... 透视脚本!微乐江苏小程序游戏破解器下载,微乐小程序辅助收费(开挂)好像是真的挂(真是有挂)-哔哩哔哩...
针对!微扑克微乐辅助,wpk有... 针对!微扑克微乐辅助,wpk有透视吗(透视)攻略教程(确实真的是有挂)1、进入到微扑克微乐辅助是否有...
随着!wepoker私人定制透... 随着!wepoker私人定制透视,wepoker透视app下载(透视)模板脚本(其实有挂)-哔哩哔哩...
出现新变化!微乐广西小程序插件... 出现新变化!微乐广西小程序插件,湖北逍遥卡五星辅助(透视)器-好像有挂1、打开软件启动之后找到中间准...