convert Expand/Collapse helper to csharp