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

效果:

在这里插入图片描述

相关内容

热门资讯

WPK插件积累!AApoker... WPK插件积累!AApoker方法,WePoKerai多功能辅助工具1、AApoker方法免费脚本咨...
正版透视挂乐乐上海麻将透视挂多... 正版透视挂乐乐上海麻将透视挂多功能AI插件,乐乐上海麻将真是是真的有透视挂插件1、乐乐上海麻将免费脚...
WPK软件总结!AApoker... WPK软件总结!AApoker透视脚本,wpkai多功能辅助神器1)AApoker透视脚本有没有挂:...
正版辅助太浪白城麻将辅助多功能... 正版辅助太浪白城麻将辅助多功能AI工具,太浪白城麻将一直真的有辅助工具1、下载好太浪白城麻将透视辅助...
WPK辅助器演示!德扑之星透视... WPK辅助器演示!德扑之星透视辅助软件是真的吗,WePoKerai多功能透视挂方法1、操作简单,无需...
正版开挂上品休闲开挂多功能AI... 正版开挂上品休闲开挂多功能AI方法,上品休闲一贯是有开挂方法1、任何上品休闲透视是真的假的的玩家都可...
WPK官网操作!德州透视插件,... WPK官网操作!德州透视插件,德州扑克ai多功能开挂教程该软件可以轻松地帮助玩家将德州透视插件外卦神...
正版辅助tx同城棋牌麻将辅助多... 正版辅助tx同城棋牌麻将辅助多功能AI攻略,tx同城棋牌麻将一直真的有辅助攻略运tx同城棋牌麻将辅助...
WPK购买窍要!wpk软件是真... WPK购买窍要!wpk软件是真的吗,WPKai多功能开挂app1、用户打开应用后不用登录就可以直接使...
正版辅助器微乐海南麻将辅助器多... 正版辅助器微乐海南麻将辅助器多功能AI软件,微乐海南麻将原来存在有辅助器软件1、微乐海南麻将免费脚本...