I have a project in which I have various Library Classes. I have a Views Library Class and a ModelViews library class. In the Views Library class I have the .xaml files corresponding to the wpf views. And in the ModelViews Library Class the commands that I use in the views. Now what I want to do is to call a new View when the user logs in, but I don't know how to do this. I have the code for logging in like this:
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");
}
}
Now, what I want to do is when the logging is successful, to close the login window and open a ListUsersView.xaml insted of showing the message "Login exitoso" inside the MessageBox. I have tried various things like creating services and helpers, but I can't put anything to work. How can I solve this? How can I call or reference a View in the ModelView class library?