简体   繁体   English

C#/ WPF:DataGrid - 最后一行/页脚行可能吗?

[英]C#/WPF: DataGrid - Last Row / Footer Row possible?

Does anyone how I can add a fixed last row / footer row to the WPF Toolkit DataGrid? 有没有人如何将固定的最后一行/页脚行添加到WPF Toolkit DataGrid? I'd like to display a "summary" at the bottom of all Column Values. 我想在所有列值的底部显示“摘要”。

Thank you. 谢谢。

Cheers 干杯

Another possibility would be to have a second DataGrid below your first grid, a summary DataGrid if you will. 另一种可能性是在第一个网格下面放置第二个DataGrid,如果愿意,可以使用摘要DataGrid。

You could perform data bindings to set the column sizings (if they are dynamic) and it would align nicely if placed in a grid layout in XAML. 您可以执行数据绑定来设置列大小(如果它们是动态的),如果放在XAML中的网格布局中,它会很好地对齐。

Hope this gives you some ideas. 希望这会给你一些想法。

I can propose another solution. 我可以提出另一个解决方案 It is base on custom collection and comparer. 它基于自定义集合和比较器。 You can adopt to your need as you want. 您可以根据需要采用您的需求。

Here is described: http://pro.ingens.ru/2012/07/cwpf-datagrid-footer-row.html 这里描述: http//pro.ingens.ru/2012/07/cwpf-datagrid-footer-row.html

In this solution footer rows won't be affected by the sorting and can be styled as you need. 在此解决方案中,页脚行不会受到排序的影响,可以根据需要进行样式设置。 Hope it helps. 希望能帮助到你。

It's probably not the best way, but this is how I solved it: 这可能不是最好的方式,但这就是我解决它的方式:

   public class MyCollectionViewModel : ObservableCollection<SomeObject>
    {
        private readonly SomeObject _totalRow;

        public MyCollectionViewModel ()
        {
            _totalRow = new SomeObject() { IsTotalRow = true; };
            base.Add(_totalRow );
        }

        public new void Add(SomeObject item)
        {
            int i = base.Count -1;
            base.InsertItem(i, item);
        }
    }

Hope this might help anyone. 希望这可以帮助任何人。

Cheers 干杯

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM