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

效果:

在这里插入图片描述

相关内容

热门资讯

第八分钟晓得!wpk透视辅助方... 第八分钟晓得!wpk透视辅助方法,佛手在线修改器(解密透视开挂辅助技巧)暗藏猫腻,小编详细说明wpk...
重大来袭!wepoker开脚本... 重大来袭!wepoker开脚本视频“科技开挂透视挂辅助软件”;重大来袭!wepoker开脚本视频“科...
第四分钟了解“新二号辅助”分析... 第四分钟了解“新二号辅助”分析开挂辅助工具-竟然是有挂新二号辅助辅助器中分为三种模型:新二号辅助软件...
第2分钟发现!wepoker破... 第2分钟发现!wepoker破解器激活码,雀友软件脚本辅助器(可靠透视开挂辅助教程)一、雀友软件脚本...
揭秘!大菠萝789辅助器下载“... 【福星临门,好运相随】;揭秘!大菠萝789辅助器下载“详细开挂透视挂辅助器”;暗藏猫腻,小编详细说明...
第8分钟晓得!wepoker俱... 第8分钟晓得!wepoker俱乐部辅助,新西部解析辅助(必备透视开挂辅助app)小薇(透视辅助)致您...
9分钟了解“闲逸软件可以控制的... 9分钟了解“闲逸软件可以控制的”必备开挂辅助软件-一直是有挂1、游戏颠覆性的策略玩法,独创攻略技巧玩...
发现玩家!wepoker有辅助... 您好,wepoker有辅助器这款游戏可以开挂的,确实是有挂的,需要了解加微【136704302】很多...
第十分钟知晓!智星德州辅助译码... 第十分钟知晓!智星德州辅助译码插件靠谱,wepoker辅助器激活码(存在挂透视开挂辅助软件)1、每一...
第3分钟了解“哥哥打大a辅助工... 第3分钟了解“哥哥打大a辅助工具视频”分享开挂辅助插件-一贯存在有挂1、哥哥打大a辅助工具视频透视辅...