public static CredToken RequestCredentials() { var loginWindowViewModel = new LoginWindowViewModel(); _windowService.ShowDialog <LoginWindow>(loginWindowViewModel); if (loginWindowViewModel.WasCanceled) { loginWindowViewModel.Dispose(); return(null); } var credtoken = new CredToken(loginWindowViewModel.Domain, loginWindowViewModel.Username, SecureStringHelper.BuildSecureString(loginWindowViewModel.Password)); return(credtoken); }