WPF DataGrid: Frozen Row Sample

It looks that this is a frequently requested feature and unfortunately didn't make the v1.  It is still possible to extend the DataGrid to do so.  A community developer has already posted a sample on creating a footer row for the DataGrid here, https://thibaud60.blogspot.com/2008/10/wpftoolkit-datagrid-with-footer-and.html.  I thought I would post a sample for creating pinned rows starting from the top.  This is similar to the excel pinning functionality. 

I won't really go into too much implementation detail but I basically follow a similar pattern to the way frozen columns are implemented.  The core of the code is in a CustomDataGridRowsPresenter.ArrangeOverride method.  I tried to make it as simple as possible so it could be easily understood and as a result of that I didn't implement virtualization.  Well, that's part of the reason I didn't implement virtualization.  VirtualizingStackPanel isn't very extendable when it comes to it's virtualization and recycling functionality.  I would have to do a good bit of my own implementation for it and it would take a good bit of time.  So, the sample only works when row and column virtualization is turned off.  If anyone feels up to making it work with virtualization, please be my guest. = ) 

Anyway, you can download the sample here.  On the left pane I added buttons to increase/decrease the frozen row and column counts. 

Note: The purpose of the sample is for learning purposes only.  Please do not use this in production code as it is not fully tested.

DataGrid_V1_FrozenRowSample.zip