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

效果:

在这里插入图片描述

相关内容

热门资讯

科技辅助挂(德州ai)伙牌(A... 科技辅助挂(德州ai)伙牌(Ai)透牌器(真是是真的有挂);1、透视辅助简单,软件透明挂操作,黑科技...
黑科技插件"aapo... 黑科技插件"aapoker猫腻!外挂透明挂辅助app(黑科技)wepoke教程"真是存在有挂;1)a...
黑科技系统(aapokEr)最... 黑科技系统(aapokEr)最新黑科技(透视)辅助使用教程(果然有挂);实战中需综合运用上述技巧,并...
黑科技好友房"智星德... 黑科技好友房"智星德州菠萝安全吗!外挂透明挂辅助工具(黑科技)透明教程"总是有挂;1、打开软件启动之...
好友房辅助挂(德州)透视辅助推... 好友房辅助挂(德州)透视辅助推荐(Ai)透视辅助器(一直是有挂)好友房辅助挂(德州)透视辅助推荐(A...
黑科技辅助(德扑ai)透明软件... 黑科技辅助(德扑ai)透明软件的使用方法(透视)辅牌器靠谱(一直是真的有挂)1、许多玩家不知道辅助软...
黑科技好友"aa p... 黑科技好友"aa poker有没有挂!外挂透明挂辅助app(黑科技)系统教程"一贯真的有挂1、构建自...
可靠黑科技(德州aapoker... 可靠黑科技(德州aapoker)辅助(透视)辅助(竟然有挂)1、完成的残局,帮助玩家取得所有比赛的胜...
黑科技系统(wPK)微扑克辅助... 黑科技系统(wPK)微扑克辅助工具(透视)稳赢的打法(原来是有挂);科技安装教程;136704302...
黑科技辅助"wpk辅... 黑科技辅助"wpk辅助!外挂透明挂辅助助手(黑科技)切实教程"其实是真的有挂wpk辅助是一种具有地方...