Is there a way in the WPF Toolkit datagrid to have a header below the column headers but above the first row

Apr 21, 2009 at 3:21 PM
I posted this same question on stack overflow:


I looking for a way to create an area that indicates a user is at the top row of the WPF Toolkit datagrid. (Showing the scrollbar scrolled down is not enough for the user). I need something that sticks out and says "this is the top row" basically. Messing with the entities that that the grid is bound to will not work for me because I have several grids with different filters over the same collection of entities. Also this underlying collections is changing while the app is running.

Is there a way to add a control of some sort between the column headers and the first row of the datagrid? Maybe a separator of some sort?

Thanks! Jon

Apr 21, 2009 at 8:42 PM
Hi Jon,

There are a few things you can do but all are fairly involved -- this is not a mainstream DataGrid scenario.  You could create a new class that inherits DataGridRowsPresenter and override OnCleanupVirtualizedItem (be sure to call the base first!) to not recycle the row if it is the first one.  Then make your DataGrid's ItemPanel point to your custom DataGridRowsPresenter.  Then style your first row in a way that makes it stand out when the window is loaded.

If you wanted to add a separator you would need to retemplate the DataGrid.

Good luck!
Apr 30, 2009 at 4:12 AM
alexir this is cool, thanks!

For discussion, what is the simplest and most effective way to show a user is at the top of a wpf datagrid?  That is the main goal of mine.  Basically I have a real time app and if a user is scrolled down, it needs to "HIT THEM IN THE FACE" that they are not at the top of the grid as the data at the top is the most important.  My grid is always updating from a background thread posting to the UI thread.  Row numbering of the grid might have been ok, but I saw another post in this forum that row numbering could possibly be done on row add, but since I have a collection that is always updated in various orders, I think the row numbers would get out of whack.

I know it seems odd for most apps but is very important for this app to get this concept built in.  Even if I had a control outside of the grid, it might be acceptable if I could bind it to some kind of dependency property like an "isscrolled" or "scrollpositionY" or anythng that I can show the user "DUDE THERE IS MORE INFO AT THE TOP AND YOU ARE SCOLLED".

Maybe styling the scroll ar would be acceptable - even though still not the greatest solution.

Any ideas?