WPF 嵌套数据网格。多层次

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21935910/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 10:58:38  来源:igfitidea点击:

WPF nested datagrids. Multiple levels

c#wpfdatagrid

提问by cmd

I'm trying to create table editor for multi-level table data using standard wpf datagrid. Is it possible to create nested structure something like this?

我正在尝试使用标准 wpf 数据网格为多级表数据创建表编辑器。是否可以创建这样的嵌套结构?

Syncfusion datagrid

同步融合数据网格

With standard row details nested grids looks ugly, because row details must have fixed height (so i will get multiple scrolls)

使用标准行细节嵌套网格看起来很难看,因为行细节必须具有固定的高度(所以我会得到多个滚动条)

My demo application

我的演示应用程序

回答by Tony Vitabile

Each DataGridcan have something called a RowDetailsTemplate. The template can have anything you want in it, including another DataGrid. If that DataGriduses the same RowDetailsTemplate, you can have a DataGridnested inside a DataGridad-infinitum.

每个都DataGrid可以有一个叫做 a 的东西RowDetailsTemplate。模板中可以包含您想要的任何内容,包括另一个DataGrid. 如果DataGrid使用相同的RowDetailsTemplate,则可以DataGridDataGrid无限循环中嵌套。

Check out this articlefor an example of using the RowDetailsTemplate. You just need to modify the XAML there to use your own template.

查看本文以获取使用RowDetailsTemplate. 您只需要修改那里的 XAML 即可使用您自己的模板。