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

效果:

在这里插入图片描述

相关内容

热门资讯

透视数据!wepoke真的有挂... 透视数据!wepoke真的有挂,wopoker真的有挂吗,详细透视第三方教程;1、wepoke真的有...
辅助透视(wePOke)wep... 辅助透视(wePOke)wepoker真的有挂吗(透视)详细辅助揭秘攻略;1分钟了解详细教程(微信 ...
透视免费!菠萝辅助器免费版的特... 透视免费!菠萝辅助器免费版的特点(透视)先前有挂(详细辅助靠谱教程);1分钟了解详细教程(微信 13...
透视存在!wpk透视辅助软件(... 透视存在!wpk透视辅助软件(透视)详细辅助新2025版(都是存在有挂)1、全新机制【wpk透视辅助...
透视ai!wepoke真的有挂... 透视ai!wepoke真的有挂,wepoke游戏真的是有挂的,详细透视曝光教程1、该软件可以轻松地帮...
透视黑科技(wePoke)wp... 1、透视黑科技(wePoke)wpk透视辅助封号吗(透视)详细辅助解密教程。2、wpk透视辅助封号吗...
透视软件!we poker游戏... 透视软件!we poker游戏下(透视)原来是真的有挂(详细辅助德州论坛)是一款可以让一直输的玩家,...
透视攻略!wpk透视脚本(透视... 透视攻略!wpk透视脚本(透视)详细辅助安装教程(果然存在有挂)1、wpk透视脚本机器人多个强度级别...
透视计算!aapoker透明挂... 透视计算!aapoker透明挂,wepoke有挂吗 网上,详细透视曝光教程一、aapoker透明挂A...
透视黑科技(wepoker)扑... 透视黑科技(wepoker)扑克时间有后台控制吗(透视)详细辅助安装教程;原来确实真的有挂(需添加指...