Hello Stephen,
RemoveAll() is a lower level method to low-level control the view tree. Dialogs implement a much higher level of functionality including transition animations and state management. Simply removing a dialog from its owner is thus not sufficient. In contrast, it will probably result in a runtime error when the dialog is dismissed.
To overcome the problem above, I limit the dialog switch operations to PresentDialog DismissDialog and SwitchToDialog. Then another problem comes out.
This is the correct approach. There is no recommendation to use RemoveAll() in context of dialogs.
B1 has A1 as its background, so I use PresentDialog and DismissDialog to switch between them. A1 and A2 are independent, so SwitchToDialog is used. When I need to switch from B1 to A2, in order to maintain a manageable dialog stack,should I call DismissDialog first to A1 and then SwitchToDialog to A2?
I don't really understand this description. I try to interpret it:
1. you present dialog B1 using PresentDialog( B1, ... ) in context of the Application component.
2. Within dialog B1 you present the dialog A1. A1 is thus subordinated to B1. You do this by using PresentDialog( A1, ... ) in context of B1.
3. Now you want to switch from B1 to A2. That means B1 and its subordinated A1 should be replaced by A2.
If this is the case, you simply invoke SwitchToDialog( A2, ... ) in context of the Application component. This will dismiss B1 and present A2. Since A1 is existing in context of B1, it will disappear too. If there is no other reference to B1 nor A1, both objects are released during the next garbage collection.
If my interpretation was wrong, please describe the situation more in detail.
Best regards
Paul Banach