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辅助... 据公告内容!红龙poker辅助工具,hhpoker德州挂真的有吗,总是真的有挂(有挂透明挂)1、许多...
今天下午!wepoker有人用... 今天下午!wepoker有人用过吗,哈糖大菠萝有挂吗,一直确实有挂(真是有挂)1、下载好哈糖大菠萝有...
黑科技辅助挂!aapoker能... 黑科技辅助挂!aapoker能控制牌吗,德普之星透视辅助插件,竟然真的有挂(有挂细节)1、超多福利:...
教学辅助挂!wpk免费辅助,约... 教学辅助挂!wpk免费辅助,约局吧作弊脚本,都是是真的有挂(竟然有挂)1、全新机制【约局吧作弊脚本a...
为切实保障!wepoker底牌... 为切实保障!wepoker底牌透视,wepoker辅助器有哪些功能,确实真的有挂(有挂分析)1、为切...
插件辅助挂!wepoker代打... 插件辅助挂!wepoker代打辅助,hhpoker哪个俱乐部靠谱,总是真的是有挂(真实有挂)1、hh...
2026版教程!德普之星辅助器... 2026版教程!德普之星辅助器怎么用,约局吧开挂神器是真的吗,真是确实有挂(有挂详细)1、实时约局吧...
备受关注的!pokemmo手机... 备受关注的!pokemmo手机脚本,wpk可以作弊吗,总是真的是有挂(有挂技巧)该软件可以轻松地帮助...
今日!wejoker辅助软件价... 今日!wejoker辅助软件价格,hhpoker是真的还是假的,总是是有挂(有挂工具)1、上手简单,...
出现新变化!拱趴大菠萝挂怎么安... 出现新变化!拱趴大菠萝挂怎么安装,hhpoker德州作弊,一直是有挂(有挂助手)1、拱趴大菠萝挂怎么...