【发布时间】:2020-03-29 20:53:26
【问题描述】:
我有一个项目,其中有各种库类。我有一个视图库类和一个模型视图库类。在 Views Library 类中,我有与 wpf 视图对应的 .xaml 文件。在 ModelViews 库类中,我在视图中使用的命令。 现在我想做的是在用户登录时调用一个新视图,但我不知道该怎么做。 我有这样的登录代码:
public void Login()
{
try
{
USUARIO usuario = bl.EncontrarUsuarioPorUsername(Usuario);
string savedPasswordHash = usuario.PASSWORD;
/* Extract the bytes */
byte[] hashBytes = Convert.FromBase64String(savedPasswordHash);
/* Get the salt */
byte[] salt = new byte[16];
Array.Copy(hashBytes, 0, salt, 0, 16);
/* Compute the hash on the password the user entered */
var pbkdf2 = new Rfc2898DeriveBytes(Password, salt, 10000);
byte[] hash = pbkdf2.GetBytes(20);
/* Compare the results */
for (int i = 0; i < 20; i++)
if (hashBytes[i + 16] != hash[i])
{
throw new UnauthorizedAccessException();
}
MessageBox.Show("Login exitoso!");
}
catch (UnauthorizedAccessException)
{
MessageBox.Show("Contrasena Incorrecta");
}
catch(NullReferenceException)
{
MessageBox.Show("Nombre de usuario incorrecto");
}
}
现在,我想要做的是当日志记录成功时,关闭登录窗口并打开一个 ListUsersView.xaml,在 MessageBox 中显示消息“Login exitoso”。我尝试过各种事情,比如创建服务和助手,但我什么都做不了。我该如何解决这个问题?如何调用或引用 ModelView 类库中的 View?
【问题讨论】:
-
你的看法是什么?这些是 Windows / UserControls 吗?
标签: c# wpf visual-studio mvvm