title: Navigate to UserControl after LoginVerification in WPF?
body: <p>I have got a Login UserControl and a ModuleHomeScreen UserControl.</p>
  
  <p>My Login UserControl has got a Username and Password TextBox and a LoginButton.
  When user clicks on LoginButton his credentials are verified from database; and then he has to be navigated to ModuleHomeScreen UserControl.</p>
  
  <p>The UserCredentials Verification is working perfectly.
  MainWindow has got a NavigationFrame where I am switching the UserControl.</p>
  
  <p>Now my problem is:
  Without filling up the user credentials, when a user clicks on login button he is still navigated to the Dashboard UserControl.
  Even there is some problem with the Navigation code !</p>
  
  <p>How do I first verify the Login Credentials and if it is successful then Navigate to different UserControl ?</p>
  
  <p>Here is my Code attached:</p>
  
  <p>Login.xaml</p>
  
  <pre><code>    public void loginButton_Click(object sender, EventArgs e)
      {
          if (LoginUserName.Text != "" &amp;&amp; LoginPassword.Password != "")
          {
              NpgsqlConnection con = new NpgsqlConnection("Server=localhost;Port=1234;UserID=postgres;Password=root;Database=postgres");
              con.Open();
              String username = LoginUserName.Text.Trim();
              String encPassword = TripleDESCrypto.Encrypt(LoginPassword.Password.Trim(),true);
              String query = "SELECT * FROM login where username= '" + username + "' and password = '" + encPassword + "';";
              NpgsqlCommand cmd = new NpgsqlCommand(query, con);
              NpgsqlDataReader dr = cmd.ExecuteReader();
              if (dr.Read())
              {
                 // ServiceContainer.GetService&lt;INavigationService&gt;().Navigate("ModuleHomeScreen", null, this);
                  LoginErrorMessage.Text = "Login Successfull";
                  MainWindow appWindow = new MainWindow();
                  ModuleHomeScreen appScreen = new ModuleHomeScreen();
                  appWindow.MainWindowNavigationFrame.Navigate(appScreen,null);
              }
              else
              {
                  LoginErrorMessage.Text = "Invalid Login Credentials.";
              }
          }
          else
          {
              LoginErrorMessage.Text = "Please enter all fields !";
          }
      }
  </code></pre>