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

效果:

在这里插入图片描述

相关内容

热门资讯

wepok软件透明挂!wepo... wepok软件透明挂!wepoke透明挂(wepokeai)总是是有挂(详细计算辅助教程);最新版2...
五分钟辅助挂!雀神小程序怎么拿... 五分钟辅助挂!雀神小程序怎么拿好牌,wepower德州原来是有挂,德州教程(有挂神器);1、雀神小程...
aapoker挂!wepoke... aapoker挂!wepoke软件透明挂多少钱,WEPoke总是真的有挂(详细外 挂教程)1、每一步...
分享实测!琼崖海南麻将助赢神器... 分享实测!琼崖海南麻将助赢神器(辅助)本来有挂(2021已更新)(哔哩哔哩)琼崖海南麻将助赢神器软件...
aa扑克辅助!AA POKER... aa扑克辅助!AA POKER下载软件,(aa扑克平台)切实有挂(详细挂教程);aa扑克辅助软件透明...
四分钟科普!丽水跑得快麻将有挂... 四分钟科普!丽水跑得快麻将有挂吗是真的吗,aapoKER竟然真的是有挂,攻略教程(有挂实操)1、用户...
WPK透视辅助!wepoke打... WPK透视辅助!wepoke打伙牌,wEPOKE一直是真的有挂(详细有辅助挂教程)WPK透视辅助辅助...
玩家交流!乐乐围棋入门有挂吗(... 玩家交流!乐乐围棋入门有挂吗(辅助)竟然真的有挂(2022已更新)(哔哩哔哩)1、每一步都需要思考,...
红龙扑克辅助挂!红龙扑克ai,... 红龙扑克辅助挂!红龙扑克ai,(红龙扑克)其实有挂(详细辅助挂教程);人气非常高,ai更新快且高清可...
7分钟攻略!至友互娱是不是有外... 7分钟攻略!至友互娱是不是有外 挂,wEpoke本来是有挂,安装教程(有挂神器)1、很好的工具软件,...