登錄成功窗體切換
1、xaml
點擊事件將登錄頁面某個控件帶回至ViewModel
<Button Content="登 錄" Command="{Binding LoginCommand}" CommandParameter="{Binding ElementName=pb_password}" Margin="30,10" Width="286" Height="40" Style="{StaticResource ButtonPrimary}"/>
2、viewmodel
/// <summary>
/// 登錄事件
/// </summary>
public RelayCommand<System.Windows.Controls.PasswordBox> LoginCommand =>
new Lazy<RelayCommand<System.Windows.Controls.PasswordBox>>(() =>
new RelayCommand<System.Windows.Controls.PasswordBox>(Login)).Value;
private void Login(System.Windows.Controls.PasswordBox password)
{
WIndex window = new WIndex();
window.Show();
Window.GetWindow(password).Close();
}