The best way to do this is to bind the visibility attribute to a boolean in your Model, e.g. use JSON like this to create your JSONModel:
modelData: { uistate: { showGroup1: true; showGroup2: false; } }
You can then update the JSONModel in your controller in response to various UI events. You can bind multiple UI5 elements to the same uistate element.
Cheers,
Shawn