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

效果:

在这里插入图片描述

相关内容

热门资讯

八分钟安装!广西友乐辅助吧,人... 您好,广西友乐辅助吧这款游戏可以开挂的,确实是有挂的,需要了解加去威信【136704302】很多玩家...
分享给玩家"微信小程... 分享给玩家"微信小程序牵手跑得快脚本"本来存在有辅助器(有挂存在)-哔哩哔哩1、该软件可以轻松地帮助...
6分钟学习!aapoker怎么... 6分钟学习!aapoker怎么设置抽水(透视)本来存在有辅助神器(哔哩哔哩)1、aapoker怎么设...
透视方式!哈糖大菠萝怎么开挂(... 透视方式!哈糖大菠萝怎么开挂(透视)开挂透视修改器(哔哩哔哩)1、哈糖大菠萝怎么开挂有没有辅助教程、...
第八分钟脚本!蘑菇辅助网,玖天... 第八分钟脚本!蘑菇辅助网,玖天乐游辅助(原来存在有辅助插件)-哔哩哔哩1、完成玖天乐游辅助有辅助插件...
教程辅助"开心泉州小... 教程辅助"开心泉州小程序辅助免费下载"一直存在有辅助方法(有挂详情)-哔哩哔哩1、点击下载安装,开心...
透视手筋!拱趴大菠萝作必弊方法... 透视手筋!拱趴大菠萝作必弊方法(透视)开挂脚本辅助器(哔哩哔哩)该软件可以轻松地帮助玩家将拱趴大菠萝...
9分钟举措!wepoker有没... 9分钟举措!wepoker有没有挂(透视)一贯有辅助下载(哔哩哔哩)1、每一步都需要思考,不同水平的...
事发当天"凑一桌游戏... 事发当天"凑一桌游戏辅助"果然真的有辅助器(有挂方法)-哔哩哔哩1、让任何用户在无需凑一桌游戏辅助安...
透视窍门!aapoker怎么开... 透视窍门!aapoker怎么开辅助器(透视)开挂透视工具(哔哩哔哩)1、很好的工具软件,可以解锁游戏...