如何更改此XAML代码来对齐行和添加头? [英] How to change this XAML code to align rows and add headers?
问题描述
使用
更新(解决有关使用DataGrid的建议): br>
问题是关于如何以类似TreeView的方式破解格式化...
DataGrid允许折叠/扩展集合的部分或者做主/细节视图,但是我找不到如何抑制重复的值,即在这种情况下是OrderName:
订单名称部件名称数量
订单1 Part11 11
订单1 Part12 12
订单2 Part21 22
订单2 Part22 22
订单2 Part23 23
它被称为分组,看看
- c-sha rpcorner.com文章在WPF中分组Datagrid。
它很好地解释了它。基本上你必须将你的集合包装在ListCollectionView中并定义GroupDescription。希望这有帮助!
ListCollectionView collection = new ListCollectionView(myOrders);
collection.GroupDescriptions.Add(new PropertyGroupDescription(OrderName);
DataGrid.ItemSource = collection;
Taking the code of this WPF application (or what is the same, this), databinding a а collection (List object (myOrders):
how to place OrderName in one line with the first line of PartNmae and PartQuantity?
how to add common headers on top of columns?
That is in place of current
I'd like to produce:
Order Name Part Name Quantity
Order1 Part11 11
Part12 12
Order2 Part21 22
Part22 22
Part23 23
Related question based on the same code example:
Update (addressing advise about using DataGrid):
The question was about how to hack the formatting in case in TreeView-like manner...
DataGrid permits to collapse/expand parts of the collection or make master/detail views but I could not find how to suppress repeating values, i.e. in this case of OrderName:
Order Name Part Name Quantity
Order1 Part11 11
Order1 Part12 12
Order2 Part21 22
Order2 Part22 22
Order2 Part23 23
It is called grouping and have a look at
- c-sharpcorner.com article "Grouping in Datagrid in WPF" .
It explains it pretty nicely. Basically you have to wrap your collection in a ListCollectionView and define the GroupDescription. Hope this helps!
ListCollectionView collection = new ListCollectionView(myOrders);
collection.GroupDescriptions.Add(new PropertyGroupDescription(OrderName);
DataGrid.ItemSource = collection;
这篇关于如何更改此XAML代码来对齐行和添加头?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!