As I see it, opening Views from ViewModels directly is a bad thing to do. Ideally, the ViewModels should work only with other ViewModels, and the Views should be created automatically. Where by automatically I mean without the ViewModel knowing, let alone intervening.
I know this is possible to achieve with controls that are included in other controls. The ViewModel can be linked to its View by including a DataTemplate in the resources of the hosting control:
<UserControl.Resources>
<DataTemplate DataType="{x:Type vm:BasicSetupViewModel}">
<vw:BasicSetupPane/>
</DataTemplate>
</UserControl.Resources>
When the ViewModel gets binded into the hosting control, its View is rendered.
However, I'm stuck when it comes to creating window Views. If I use the same approach as with included controls, I get this exception:
System.Windows.Markup.XamlParseException: 'Window must be the root of the tree. Cannot add Window as a child of Visual.'
Which makes sense. Yet I can't think of any other way of telling the application that the window should be generated. Is there any?