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

效果:

在这里插入图片描述

相关内容

热门资讯

实测教程!wepoker内置辅... 实测教程!wepoker内置辅助器,wejoker内置辅助,专业教程(了解有挂);一、玩家揭秘wep...
我来教大家!吉祥填大坑脚本,p... 您好:吉祥填大坑脚本这款游戏可以开挂的,确实是有挂的,很多玩家在这款游戏中打牌都会发现很多用户的牌特...
9分钟了解!宁波同乐游辅助下载... 9分钟了解!宁波同乐游辅助下载,wepoker好友局透视,力荐教程(有挂详细);宁波同乐游辅助下载免...
重要通知!欢乐联盟卡五星辅助,... 重要通知!欢乐联盟卡五星辅助,wepoker有用吗,细节方法(有挂秘籍)是一款可以让一直输的玩家,快...
研究成果!九九联盟解码器,we... 研究成果!九九联盟解码器,wepoker免费脚本咨询,wepoke教程(有挂讲解);九九联盟解码器最...
带你了解!多乐辅助app,hh... 【福星临门,好运相随】;带你了解!多乐辅助app,hhpoker辅助挂下载,透牌教程(有挂头条);暗...
总算了解!来几局辅助器开挂,h... 总算了解!来几局辅助器开挂,hhpoker辅助挂是真的吗,透明挂教程(有挂讲解);来几局辅助器开挂免...
必看攻略!微信呢小程序辅助器,... 必看攻略!微信呢小程序辅助器,wepoker透视脚本下载,大神讲解(有挂实锤),微信呢小程序辅助器是...
每日必备!长春科乐天天踢辅助,... 每日必备!长春科乐天天踢辅助,pokemmo脚本辅助,总结教程(有挂方式);1、让任何用户在无需AI...
发现一款!闲来辅助神器怎么下载... 您好:闲来辅助神器怎么下载这款游戏可以开挂的,确实是有挂的,很多玩家在这款游戏中打牌都会发现很多用户...