Quantcast
Viewing all articles
Browse latest Browse all 18858

"Window must be the root of the tree. Cannot add Window as a child of Visual."

Hello There.

I have an existing project, that I am now refactoring into the MVVM design pattern; This involved having multiple Views, that in short, is the xaml. Problem is, I have an application entry point xaml, with a place holder in it. In its code behind, I instantiate my desired view, and then assign it to the placeholder. however I get the message:

Message = "Window must be the root of the tree. Cannot add Window as a child of Visual."

It is not possible for me to just change the Window type to Page or UserControl, because the xaml and most of the other code behind, makes use of Window specific tests. Such as: 

if (WindowState == WindowState.Minimized) ...., etc.

So how do I go about fixing this conundrum? Any ideas please go ahead and share.

Peace out. 


Viewing all articles
Browse latest Browse all 18858

Trending Articles