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可以... 透视黑科技!wepoker可以开透视吗,werplan有挂吗,秘籍教程(切实存在有挂)-哔哩哔哩小薇...
透视控制!hhpoker透视脚... 透视控制!hhpoker透视脚本视频(透视)开挂辅助插件(果然有挂)-哔哩哔哩运hhpoker透视脚...
据了解!长春科乐天天踢辅助,微... 据了解!长春科乐天天踢辅助,微信小程序微乐房间怎么开挂,攻略教程(原来真的有挂)-哔哩哔哩微信小程序...
透视教程!wepoker可以透... 透视教程!wepoker可以透视码,hhpoker软件安装包,积累教程(其实真的有挂)-哔哩哔哩1、...
此事引发网友热议!顺欣茶楼开挂... 此事引发网友热议!顺欣茶楼开挂,欢聚水鱼脚本,技巧教程(切实是真的挂)-哔哩哔哩1.顺欣茶楼开挂 a...
透视辅助!pokerworld... 透视辅助!pokerworld软件(透视)开挂辅助挂(一贯存在有挂)-哔哩哔哩1、这是跨平台的pok...
透视攻略!pokermaste... 透视攻略!pokermaster修改器,wepoker脚本,手段教程(一贯是有挂)-哔哩哔哩透视攻略...
透视大厅!wepoker是不是... 透视大厅!wepoker是不是有人用挂(透视)开挂辅助挂(其实有挂)-哔哩哔哩1、wepoker是不...
据权威媒体报道!手机游戏挂机辅... 据权威媒体报道!手机游戏挂机辅助,决战卡五星辅助源码,攻略教程(确实是真的挂)-哔哩哔哩决战卡五星辅...
透视软件!有没有人wepoke... 透视软件!有没有人wepoker,约局吧德州可以透视吗,烘培教程(本来真的是有挂)-哔哩哔哩1、下载...