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

效果:

在这里插入图片描述

相关内容

热门资讯

wepoker底牌透视脚本ht... wepoker底牌透视脚本http!hhpkoer辅助器视频(透视)一直有挂(攻略教程);1、不需要...
wpk透视辅助!wpk德州透视... wpk透视辅助!wpk德州透视辅助(透视)总是是真的有挂(详细辅助揭秘几款)1、很好的工具软件,可以...
透视软件!hhpoker透视下... 透视软件!hhpoker透视下载链接在哪里,wpk有脚本吗,分享一款(有挂规律);是一款可以让一直输...
透视实锤!wepoker透视,... 透视实锤!wepoker透视,wpk脚本辅助器,可靠技巧(有挂详情);1、上手简单,内置详细流程视频...
wepoker底牌透视脚本ap... wepoker底牌透视脚本app!wepoker透视有用吗(透视)果然真的是有挂(揭秘攻略)1、让任...
德扑之星辅助器购买!wepok... 德扑之星辅助器购买!wepoke辅助技巧(透视)一向真的是有挂(详细辅助盘点几款)(1)德扑之星辅助...
透视挂透视!wpk脚本是什么,... 透视挂透视!wpk脚本是什么,红龙poker有辅助吗,科普分享(有挂技巧);是一款可以让一直输的玩家...
透视软件!wpk辅助器安装,a... 透视软件!wpk辅助器安装,aapoker脚本怎么用,爆料教程(有挂细节)1、下载好aapoker脚...
hhpoker透视脚本视频!n... 您好,hhpoker透视脚本视频这款游戏可以开挂的,确实是有挂的,需要了解加去Q群【10672391...
wpk透视辅助!wepoke辅... wpk透视辅助!wepoke辅助(透视)一直是真的有挂(详细辅助免费测试版)1、不需要AI权限,帮助...