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辅助软件价格(透视)wepoker能不能透视(切实真的有挂)wepoker辅...
透视计算!德州透视脚本(透视)... 透视计算!德州透视脚本(透视)黑科技教程(2020已更新)(哔哩哔哩)1、用户打开应用后不用登录就可...
透视苹果版!wepoker透视... 透视苹果版!wepoker透视脚本(透视)辅助是真的假的(原来是有挂)1、点击下载安装,wepoke...
透视插件!wepokerplu... 透视插件!wepokerplus脚本(透视)wepoker是不是有人用挂(都是有挂)1、wepoke...
透视挂!pokermaster... 透视挂!pokermaster脚本(透视)必胜教程(2022已更新)(哔哩哔哩);1、pokerma...
透视ai代打!wepoker透... 透视ai代打!wepoker透视脚本免费使用视频(透视)辅助透视软件(一直真的是有挂)1、首先打开w...
透视脚本!WePoKer辅助器... 透视脚本!WePoKer辅助器(透视)wepoker脚本下载(竟然是有挂)1、下载好wepoker脚...
透视好友!wepoker有没有... 透视好友!wepoker有没有机器人(透视)有机器人(都是有挂)1、让任何用户在无需wepoker有...
透视存在!哈糖大菠萝有挂吗(透... 透视存在!哈糖大菠萝有挂吗(透视)可靠技巧(2023已更新)(哔哩哔哩);哈糖大菠萝有挂吗辅助器中分...
透视ai!wepokerplu... 透视ai!wepokerplus到底是挂了吗(透视)wepoker私人局透视教程(总是存在有挂);1...