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

效果:

在这里插入图片描述

相关内容

热门资讯

正版开挂!心悦手游辅助,hhp... 正版开挂!心悦手游辅助,hhpkoer辅助挂是真的吗,存在挂教程(有挂存在)-哔哩哔哩1、下载安装好...
最初有开挂"德普之星... 最初有开挂"德普之星辅助软件"详细开挂辅助工具有挂秘籍(技巧教程)您好:德普之星辅助软件这款游戏可以...
了解开挂!财神13章脚本.(透... 了解开挂!财神13章脚本.(透视)we poker辅助器下载(安装教程开挂辅助神器)1、下载安装好w...
透视教学!八一字牌脚本,微乐游... 透视教学!八一字牌脚本,微乐游戏小程序(透视)开挂辅助插件微扑克教程;无需打开直接搜索打开薇:136...
关于开挂!欢聚水鱼脚本,wep... 关于开挂!欢聚水鱼脚本,wepoker底牌透视,新2026教程(有挂总结)-哔哩哔哩您好:欢聚水鱼脚...
起初有辅助"wepo... 起初有辅助"wepoker辅助器安装包定制"详细开挂辅助挂真的有挂(2026新版教程);无需打开直接...
盘点辅助!爱来掌中宝辅助器(透... 盘点辅助!爱来掌中宝辅助器(透视)aapoker脚本(AI教程开挂辅助脚本)爱来掌中宝辅助器ai黑科...
透视数据!微信超级3+1辅助,... 透视数据!微信超级3+1辅助,wepoker有插件吗(透视)开挂辅助挂可靠教程;无需打开直接搜索打开...
曝光开挂!友间十三道有什么窍门... 大家好,今天小编来为大家解答友间十三道有什么窍门这个问题咨询软件客服可以免费测试直接加微信(1367...
原先有开挂"微乐富足... 微乐富足和靠谱吗 无需打开直接搜索微信:136704302本司针对手游进行,选择我们的四大理由: 1...