Click here to Skip to main content
13,093,531 members (77,391 online)
Click here to Skip to main content
Add your own
alternative version


2 bookmarked
Posted 25 Jun 2012

ListView with Footer

, 25 Jun 2012
Rate this:
Please Sign up or sign in to vote.
A listview control with footer.


A footer row with the column totals frozen at the bottom is a fairly common item on grids. You can probably get one by using a DataGrid, but there’s a good deal of complexity associated with DataGrids you might want to avoid.

Using the Code

I made a Custom Control ListViewF based on the standard ListView. You need to supply the ListViewF with a FooterObj which should be the same type of object you are displaying in the regular rows. You can specify a FooterStyle. Both FooterObj and FooterStyle can be instantiated in the XAML.

You will need to call the ListViewF.InitFooter function after the columns have loaded. The function creates a CellTemplateSelector for each GridViewColumn.

If the column is using DisplayMemberBinding it creates two CellTemplates – one for the regular cells and one for the footer. The regular cell template is just a TextBlock with the Text bound to whatever the DisplayMemberBinding was. The footer is the same but wrapped in a Border. The original DisplayMemberBinding is cleared so the DataTemplateSelector can be used.

If the column is using a CellTemplate it creates a footer template by adding a ContentPresenter with the original template as the ContentTemplate and then wrapping the ContentPresenter in a Border.

I don’t handle cases where the column already has a CellTemplateSelector. It shouldn’t be too hard to create a new selector that calls the original CellTemplateSelector and then either returns the original template or wraps it in a Border.

Points of Interest

You need to use a custom GridView that overrides the DefaultStyleKey. If you add columns using a normal GridView the Control goes back to using the regular ListView template.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

United States United States
No Biography provided

You may also be interested in...

Comments and Discussions

QuestionPost back remove the footer row Pin
Ali John1-Sep-15 1:45
memberAli John1-Sep-15 1:45 
QuestionOne small improvement Pin
2irfanshaikh2-Jul-12 1:18
member2irfanshaikh2-Jul-12 1:18 
AnswerRe: One small improvement Pin
MikeLamb111-Jul-12 16:09
memberMikeLamb111-Jul-12 16:09 
GeneralRe: One small improvement Pin
serine8619-May-13 7:15
memberserine8619-May-13 7:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.170813.1 | Last Updated 25 Jun 2012
Article Copyright 2012 by MikeLamb1
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid