Ok, so the problem seems to be the following: When created, the GoSubGraph is in the Expanded state. Initializing in this state does not imply any call to PrepareExpand (that is understandable).
Then I read some data from a file to see if the subgraph should be expanded or not, and depending on this data, I call expand or collapse. This call to expand is effectively a no-op, since the graph was initialized as expanded.
In my case, however, I have some work that only has to be done when (if?) the graph is expanded (loading the subgraph content). So putting this code in prepareExpand is just not a solution. I wonder what would be the best solution :
- Overriding Expand and move that initialisation code here, before calling base class Expand.
- Change the code to that the initial state is collapsed, since it is what fits my model best. Is there a way to do so ? I might just call Collapse at the beginning of the constructor, then read my config file and potentially call Expand, but I don’t know why, this looks unnatural to me.