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辅助器下载!技巧知识分享辅助工具(真的有挂)-哔哩哔哩1、每一步都需要思考,...
今日!德州透视是真的吗(透视)... 今日!德州透视是真的吗(透视)切实是真的辅助插件(今日头条)-哔哩哔哩1、操作简单,无需德州透视是真...
了解透视!wpk作弊最怕三个东... 了解透视!wpk作弊最怕三个东西!程序员教你辅助挂(有挂攻略)-哔哩哔哩1)wpk作弊最怕三个东西辅...
透视辅助!wepoker怎么挂... 透视辅助!wepoker怎么挂飞机(透视)确实是真的辅助工具(存在有挂)-哔哩哔哩进入游戏-大厅左侧...
推荐透视!wpk插件!玩家必看... 推荐透视!wpk插件!玩家必看辅助方法(有挂细节)-哔哩哔哩wpk插件破解侠是真的助透视。每个模型中...
透视存在!xpoker辅助控制... 透视存在!xpoker辅助控制(透视)原来存在有辅助神器(真的有挂)-哔哩哔哩1、玩家可以在xpok...
关于透视!hhpoker真的假... 关于透视!hhpoker真的假的!记者揭秘辅助工具(有挂细节)-哔哩哔哩1)hhpoker真的假的免...
透视真的!aapoker ai... 透视真的!aapoker ai插件(透视)本来有辅助安装(证实有挂)-哔哩哔哩aapoker ai插...
现有说明如下!红龙poker辅... 现有说明如下!红龙poker辅助平台(透视)一直有辅助app(真的有挂)-哔哩哔哩1、这是跨平台的红...
解迷透视!wepoker有机器... 您好,wepoker有机器人吗这款游戏可以开挂的,确实是有挂的,需要了解加去威信【485275054...