简体   繁体   中英

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? 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.

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.

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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