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作必弊是真的吗(透视)开挂脚本神器(哔哩哔哩)1、完成wpk作必弊是真的吗有辅助插件...
目前"大唐山西辅助软... 目前"大唐山西辅助软件"总是真的是有辅助教程(有挂透视)-哔哩哔哩1、起透看视 大唐山西辅助软件辅助...
第6分钟安装!新广西老友辅助,... 第6分钟安装!新广西老友辅助,哥哥打大a脚本(一贯真的有辅助平台)-哔哩哔哩1、进入到新广西老友辅助...
第9分钟举措!pokerrrr... 第9分钟举措!pokerrrr2辅助(透视)本来是有辅助工具(哔哩哔哩)1、完成pokerrrr2辅...
现就发布提示"jj斗... 现就发布提示"jj斗地主辅助"一贯存在有辅助脚本(有挂解密)-哔哩哔哩1、游戏颠覆性的策略玩法,独创...
透视绝活!hhpoker是内部... 透视绝活!hhpoker是内部控制吗(透视)开挂脚本app(哔哩哔哩)该软件可以轻松地帮助玩家将hh...
一分钟课程!wepoker能不... 一分钟课程!wepoker能不能透视(透视)真是真的有辅助神器(哔哩哔哩)wepoker能不能透视辅...
第7分钟脚本!禅游辅助,皮皮衡... 第7分钟脚本!禅游辅助,皮皮衡阳字牌黑科技视频(确实存在有辅助插件)-哔哩哔哩1、玩家可以在皮皮衡阳...
透视阶段!wpk免费辅助(透视... 透视阶段!wpk免费辅助(透视)开挂透视软件(哔哩哔哩);1、玩家可以在wpk免费辅助透视最简单三个...
揭秘关于"情怀莆仙脚... 揭秘关于"情怀莆仙脚本辅助器"都是是有辅助神器(有挂辅助)-哔哩哔哩1、游戏颠覆性的策略玩法,独创攻...