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

效果:

在这里插入图片描述

相关内容

热门资讯

透视步骤!德普之星的辅助工具介... 透视步骤!德普之星的辅助工具介绍,德普之星辅助工具如何打开(透视)原来真的有脚本工具(哔哩哔哩)1)...
透视积累!德普之星的辅助工具介... 透视积累!德普之星的辅助工具介绍,德普之星辅助工具如何设置(透视)好像是有脚本神器(哔哩哔哩)进入游...
透视方案!hhpoker到底可... 透视方案!hhpoker到底可以作必弊吗,hhpoker透视脚本视频(透视)一直真的有透视技巧(哔哩...
透视诀窍!hhpoker外开挂... 透视诀窍!hhpoker外开挂靠谱吗,hhpoker透视脚本视频(透视)好像有脚本软件(哔哩哔哩)透...
透视方案!红龙poker有辅助... 透视方案!红龙poker有辅助吗,werplan辅助软件(透视)都是真的有透视器(哔哩哔哩)1、红龙...
透视法门!wpk官网下载链接,... 透视法门!wpk官网下载链接,wpk安卓下载辅助(透视)果然真的是有脚本神器(哔哩哔哩)wpk官网下...
透视技法!wpk可以作必弊吗,... 透视技法!wpk可以作必弊吗,wpk刷入池率脚本(透视)果然是真的脚本app(哔哩哔哩)1、上手简单...
透视模板!德州私人局脚本,红龙... 透视模板!德州私人局脚本,红龙poker辅助平台(透视)果然是有脚本app(哔哩哔哩)1、实时红龙p...
透视教材!德普辅助器怎么用,德... 透视教材!德普辅助器怎么用,德普之星辅助器怎么用(透视)一贯有脚本app(哔哩哔哩)1、德普之星辅助...
透视练习!wepoker软件靠... 透视练习!wepoker软件靠谱么,wepoker线上大神(透视)本来有透视挂(哔哩哔哩)1、进入到...