You should not open a another view from ViewModel because it is against the MVVM pattern as "Hari p balineni" already said. So, instead of Creating Login Window, You can convert it into the UserControl and place it into your main window like
<v:logincontrol x:name="loginControl" height="270" width="560" xmlns:x="#unknown" xmlns:v="#unknown" />
and at code behind of the Login UserControl
public partial class LoginControl : UserControl
{
private UIElement parent;
private string Username;
private string Password;
public ThreatBaseInformationTemplateV2()
{
InitializeComponent();
this.Visibility = System.Windows.Visibility.Hidden;
}
public void SetParent(UIElement parent)
{
this.parent = parent;
}
public void ShowHandlerDailog()
{
this.Visibility = System.Windows.Visibility.Visible;
this.parent.IsEnabled = false;
}
public void HideHandlerDialog()
{
this.Visibility = System.Windows.Visibility.Hidden;
this.parent.IsEnabled = true;
}
private void btnLogin_Click(object sender, RoutedEventArgs e)
{
Username = txtUsername.Text;
Password = txtPassword.Text;
this.parent.IsEnabled = true;
this.Visibility = System.Windows.Visibility.Hidden;
}
private void btnCancel_Click(object sender, RoutedEventArgs e)
{
this.parent.IsEnabled = true;
this.Visibility = System.Windows.Visibility.Hidden;
}
}
Now, In the constructor of the MainWindow you can set the parent of this control like
this.loginControl.SetParent(KBEditor);
and the you can show this on LoadEvent of MainWindow.
Hope it will help.