C # / WPF: DataGrid - last row row / footer?

Can anyone add a fixed last row of a row / footer in a DataGrid Toolkit WPF? I would like to display a β€œsummary” at the bottom of all the column values.

Thanks.

Greetings

+6
c # wpf footer datagrid
source share
3 answers

This is probably not the best way, but 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 can help anyone.

Greetings

0
source share

Another possibility would be to have a second DataGrid below your first grid, the resulting DataGrid, if you do.

You can do data bindings to set the values ​​of the columns (if they are dynamic), and it will align well if it fits into the grid layout in XAML.

Hope this gives you some ideas.

+3
source share

I can offer another solution. It is based on a custom collection and comparator. You can adapt to your needs as you wish.

It is described here: http://pro.ingens.ru/2012/07/cwpf-datagrid-footer-row.html

In this solution, the footer lines will not be affected by sorting and can be styled as needed. Hope this helps.

0
source share

All Articles