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

效果:

在这里插入图片描述

相关内容

热门资讯

透视解密!德州辅助工具到底怎么... 透视解密!德州辅助工具到底怎么样,红龙poker作弊指令-本来真的是有辅助神器(哔哩哔哩)1、超多福...
透视解谜!wepoker私人局... 透视解谜!wepoker私人局怎么玩,wepoker买脚本靠谱吗-确实真的有辅助攻略(哔哩哔哩)所有...
透视解密!约局吧德州可以透视吗... 透视解密!约局吧德州可以透视吗,aa poker辅助-果然真的有辅助攻略(哔哩哔哩)1、透视解密!约...
透视普及!wpk俱乐部是真的吗... 透视普及!wpk俱乐部是真的吗,wpk真吗-原来真的有辅助技巧(哔哩哔哩)进入游戏-大厅左侧-新手福...
透视解密!wepoker作弊视... 透视解密!wepoker作弊视频,wepoker怎么挂底牌-其实有辅助app(哔哩哔哩)1、操作简单...
透视科普!德普软件,德普之星透... 透视科普!德普软件,德普之星透视辅助软件是真的吗-总是一直总是有辅助插件(哔哩哔哩)1、许多玩家不知...
透视有挂!wepoker俱乐部... 透视有挂!wepoker俱乐部辅助,wepoker免费脚本咨询-确实有辅助脚本(哔哩哔哩)进入游戏-...
透视揭露!wpk辅助哪里买,w... 透视揭露!wpk辅助哪里买,wpk辅助购买-切实是有辅助软件(哔哩哔哩)1、进入到是否有挂之后,能看...
透视辅助!约局吧辅助器,来玩a... 透视辅助!约局吧辅助器,来玩app破解-真是真的有辅助插件(哔哩哔哩)1、约局吧辅助器破解器简单,约...
透视揭幕!agpoker辅助,... 透视揭幕!agpoker辅助,智星德州插件怎么下载-好像一直都是有辅助插件(哔哩哔哩)1、游戏颠覆性...