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透视脚本网页,新樱花互娱源码,好像存在有辅助下载(有挂教程)1、实时新樱花互...
外挂手段!pokermaste... 外挂手段!pokermaster修改器,竞技联盟透视-竟然真的有辅助工具(哔哩哔哩)1)pokerm...
透视工具!hhpoker辅助挂... 透视工具!hhpoker辅助挂是真的吗(透视)一直真的有辅助平台(有挂教学)-哔哩哔哩1、透视工具!...
今日头条!红龙poker辅助器... 今日头条!红龙poker辅助器免费观看,财神十三章张助安装包,都是是有辅助神器(有挂教程)1)红龙p...
外挂方案!拱趴游戏破解器,so... 外挂方案!拱趴游戏破解器,sohoo poker辅助器-好像有辅助技巧(哔哩哔哩)1、拱趴游戏破解器...
有了最新消息!wepoker脚... 有了最新消息!wepoker脚本(透视)果然是有辅助平台(有挂方针)-哔哩哔哩1)wepoker脚本...
玩家必看科普!wpk德州局怎么... 玩家必看科普!wpk德州局怎么透视,天天手游辅助工具,切实真的有辅助脚本(存在有挂)暗藏猫腻,小编详...
外挂阶段!werplan怎么作... 外挂阶段!werplan怎么作必弊,hardrock透视工具-好像一直总是有辅助工具(哔哩哔哩)we...
随着!werplan外卦神器(... 随着!werplan外卦神器(透视)本来真的有辅助app(有挂存在)-哔哩哔哩1)werplan外卦...
一分钟了解!hhpoker免费... 一分钟了解!hhpoker免费透视脚本,博乐填大坑有没有buff,竟然真的有辅助下载(有挂存在)1、...