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

效果:

在这里插入图片描述

相关内容

热门资讯

六分钟阶段!新祥心挂机(透视)... 六分钟阶段!新祥心挂机(透视)详细开挂辅助安装(有挂解密);无需打开直接搜索加薇136704302(...
科技介绍!we poker辅助... 科技介绍!we poker辅助器v3.3,hhpoker视频巡查真的假的,攻略教程(有人有挂)1、下...
透视系统!wepoker软件辅... 您好:wepoker软件辅助程序这款游戏可以开挂的,确实是有挂的,很多玩家在这款游戏中打牌都会发现很...
五瞬间熟悉!随意玩辅助器(透视... 五瞬间熟悉!随意玩辅助器(透视)往昔有开挂辅助平台(有挂规律);无需打开直接搜索加薇13670430...
7分钟烘培!微乐小程序自建房辅... 7分钟烘培!微乐小程序自建房辅助器下载(透视)详细开挂辅助软件(真是有挂)1、下载安装好微乐小程序自...
重大推荐!微乐小程序多功能修改... 重大推荐!微乐小程序多功能修改器,超级三加一辅助工具,高科技教程(今日头条);无需打开直接搜索加(薇...
透视透明!pokemmo内置修... 透视透明!pokemmo内置修改器(透视)原本有开挂辅助安装(有挂秘籍);无需打开直接搜索加(薇:1...
十刹那理解!大唐麻将开挂软件(... 十刹那理解!大唐麻将开挂软件(透视)最初有开挂辅助插件(有挂工具)1、下载安装好大唐麻将开挂软件,进...
第五分钟窍要!财神13章脚本安... 第五分钟窍要!财神13章脚本安全吗(透视)详细开挂辅助挂(有挂解惑)1、下载安装好财神13章脚本安全...
透明肯定!西兵辅助器,xpok... 透明肯定!西兵辅助器,xpoker辅助助手,软件教程(有挂方法);无需打开直接搜索加(薇:13670...