In case this is relevant; I am using Caliburn.Micro and Castle.Windsor in my WPF application.
I have a LoginView with a LoginViewModel, which is launched on application startup without dramas. Then, once the user logs in, from within the LoginViewModel, I launch a SplashScreen, and the Main app view like so;
IoC.Get<IWindowManager>().ShowWindow(IoC.Get<SplashScreenViewModel>());
IoC.Get<IWindowManager>().ShowWindow(IoC.Get<MainViewModel>());
The first call works, the second throws an exception inside Caliburn.Micro where it calls;
Window.Show();
The InvalidOperationException
message is: "Window must be the root of the tree. Cannot add Window as a child of Visual."
My understanding is that Window.Show() puts the Window at the root of the Visual Tree... also, more or less this same code is working fine in a prior revision of this codebase, but I've done some major refactoring in other areas, and now this has cropped up.
I'm guessing there's some fail in a related refactor around my use of Castle.Windsor or Caliburn.Micro but this error message is not helping me work out what that might be...
Any suggestions?