HeaderPersister
is a small utility class that persist the header of individual GroupItem
s while scrolling. It is not tied to any particular ItemsControl
derived class, I confirmed a correct behavior for ListBox
, ListView
and TreeView
.
The usage of the HeaderPersister
is straightforward, make sure to:
- Bind to your
CollectionViewSource
instance and define yourGroupDescriptions
collection. - Set the attached property
HeaderPersister.IsEnabled
totrue
. - Duplicate the visual tree of the
GroupItem
header in theHeaderPersister.HeaderTemplate
attached property.
For more information, check the following blog post: http://blog.qarim.net/2013/08/16/wpf-persistent-group-headers-for-the-listbox-control/