Add support for expanding and collapsing programmatically