WPF MVVM 关闭当前窗体 打开新的窗体

登录成功窗体切换

1、xaml

点击事件将登录页面某个控件带回至ViewModel

2、viewmodel

/// 
        /// 登录事件
        /// 
        public RelayCommand LoginCommand =>
            new Lazy>(() =>
                new RelayCommand(Login)).Value;
private void Login(System.Windows.Controls.PasswordBox password)
{
    WIndex window = new WIndex();
                        window.Show();

                        Window.GetWindow(password).Close();
}

 

你可能感兴趣的:(WPF)