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

效果:

在这里插入图片描述

相关内容

热门资讯

总算了解!gg扑克软件,微扑克... 总算了解!gg扑克软件,微扑克德州专用辅助器,插件教程(原先有挂)1、不需要AI权限,帮助你快速的进...
aapoker外挂!aapok... aapoker外挂!aapoker ai,(aapoker下载)总是是真的有挂(详细辅助新2025教...
wepower有外 挂(透视)... wepower有外 挂(透视)wepoke是什么软件(详细辅助新2025教程)一直是有挂(详细确实有...
微扑克辅助机器人(微扑克)微扑... 微扑克辅助机器人(微扑克)微扑克有没有挂(透视)本来有挂(详细辅助详细教程);1、全新机制【微扑克辅...
终于发现!德州之星手游辅助,智... 自定义智星德州菠萝系统规律,只需要输入自己想要的开挂功能,一键便可以生成出微扑克专用辅助器,不管你是...
aapoker透视辅助!aa扑... aapoker透视辅助!aa扑克有挂吗,(aapoker教程)果然是真的有挂(详细辅助安装教程);支...
发现一款!德扑人工智能,微扑克... 发现一款!德扑人工智能,微扑克有辅助挂,详细教程(本来存在有挂)1)微扑克有辅助挂辅助挂:进一步探索...
WePoKe外 挂(透视)we... WePoKe外 挂(透视)wepower插件(详细辅助详细教程)真是真的是有挂(普及辅助技巧)1、不...
微扑克游戏辅助器(微扑克)微扑... 微扑克游戏辅助器(微扑克)微扑克有没有辅助(透视)总是是真的有挂(详细辅助揭秘教程)1、构建自己的微...
aapoker辅助工具!aap... aapoker辅助工具!aapoker辅助是真的吗,(aa poker辅助软件)竟然是有挂(详细辅助...