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

效果:

在这里插入图片描述

相关内容

热门资讯

透视辅助!werplan怎么透... 透视辅助!werplan怎么透视,pokemmo脚本,科技开挂辅助脚本(透视真的有挂)【无需打开直接...
大家学习交流“wejoker辅... 大家学习交流“wejoker辅助器怎么卖”开挂(透视)辅助脚本(可靠技巧有挂方式);无需打开直接搜索...
透视辅助!werplan有挂吗... 透视辅助!werplan有挂吗,wepoker一直输的号能继续打吗,分享开挂辅助下载(透视有挂方式)...
推荐一款“德普辅助器怎么用”开... >>您好:确实是有挂的,很多玩家在这款游戏中打牌都会发现很多用户的牌特别好,总是好牌,而且好像能看到...
透视辅助!拱趴大菠萝怎么开挂,... 透视辅助!拱趴大菠萝怎么开挂,hhpoker软件可以玩吗,通报开挂辅助神器(透视真的有挂)【无需打开...
终于知道“pokermaste... 终于知道“pokermaster脚本”开挂(透视)辅助工具(透明挂教程有挂详情)《详细加薇13670...
透视辅助!wejoker免费脚... 透视辅助!wejoker免费脚本,佛手在线大菠萝为什么都输,关于开挂辅助插件(透视有挂秘笈);无需打...
透视有挂“aapoker怎么控... 透视有挂“aapoker怎么控制牌”开挂(透视)辅助神器(细节方法详细教程)您好:这款游戏可以开挂,...
透视辅助!wepoker提高好... 透视辅助!wepoker提高好牌率,购买wepoker模拟器,推荐开挂辅助安装(透视有挂教程)1、下...
发现一款“wpk辅助器”开挂(... 发现一款“wpk辅助器”开挂(透视)辅助工具(实用技巧有挂方法)【无需打开直接搜索加薇1367043...