The accepted answer is wrong as explained in the comments. I wrote the following behavior which achieves the desired functionality:
public class PersistGroupExpandedStateBehavior : Behavior
{
#region Static Fields
public static readonly DependencyProperty GroupNameProperty = DependencyProperty.Register(
"GroupName",
typeof(object),
typeof(PersistGroupExpandedStateBehavior),
new PropertyMetadata(default(object)));
private static readonly DependencyProperty ExpandedStateStoreProperty =
DependencyProperty.RegisterAttached(
"ExpandedStateStore",
typeof(IDictionary
It attaches a dictionary to the containing ItemsControl which saves the expanded state for every group item. This will be peristent, even if the items in the control changes.