title: How to change password
body: <p>I'm making an app right now with VisualStudio, and I'm using XAML and C#.
  I'm making an app where you can enter a password (existing of numbers only), by clicking on buttons.</p>
  
  <p>If you click on <strong>"button 1",</strong> it will write a <strong>"1"</strong> in a label, and if you click on <strong>"button 2"</strong> afterwards, it will add a <strong>"2",</strong> making it <strong>"12"</strong> in total.</p>
  
  <p>If you enter the correct code, like <strong>"331122",</strong> then you have to press on a button, and a message will pop up saying it is the correct code.</p>
  
  <p>If you fail, then you'll get an error message.</p>
  
  <p>I've also added a <strong>"clear"</strong> button, that wipes out what you've entered. So far so good. Now I want to add a new button, which will bring you to a <code>passwindow</code> where you can enter your current password (which is the default password: <strong>"331122"</strong>), and a new password.</p>
  
  <p>If your entered password in the current-password-box matches the default password, your default password will change to the new password you've typed in, if you click on a button below.</p>
  
  <p>If it's incorrect, you'll get an error saying it's incorrect. When you change your password, you should be able to type it in the <code>MainWindow</code> app (by clicking the buttons). The old password has to be completely wiped out, and you should be able to keep on changing your password.</p>
  
  <p>I'm stuck on this.</p>
  
  <p><strong>Here's the code:</strong></p>
  
  <pre><code>string defaultCode = "331122";
  
  public MainWindow()           
  {
      InitializeComponent();
  }
  
  //string defaultCode = "331122";
  
  private void knop_1_Click(object sender, RoutedEventArgs e)
  {
      label_Combinatie.Content += "1";
  }
  
  private void knop_2_Click(object sender, RoutedEventArgs e)
  {
      label_Combinatie.Content += "2";
  }
  
  private void knop_3_Click(object sender, RoutedEventArgs e)
  {
      label_Combinatie.Content += "3";
  }
  
  private void knop_klaar_Click(object sender, RoutedEventArgs e)
  {
      if ((string)label_Combinatie.Content == defaultCode)
      {
          MessageBox.Show("Unlocked.");
      }
      else
      {
          MessageBox.Show("You've entered the wrong code. Please try again.");
      }
  }
  
  private void knop_reset_Click(object sender, RoutedEventArgs e)
  {
      label_Combinatie.Content = "";
  }
  
  private void knop_verander_code_Click(object sender, RoutedEventArgs e)
  {
      passwindow w = new passwindow();
      w.ShowDialog();
  }
  
  public passwindow w { get; set; }
  
  private void button_changePw_Click(object sender, RoutedEventArgs e)
  {
      string new_code;
      new_code = w.textBox_new_code.Text;
      defaultCode = w.textBox_current_code.Text;
  
      if (w.textBox_current_code.Text == defaultCode &amp;&amp; w.textBox_new_code.Text == new_code)
      {
          defaultCode = "";
          new_code += defaultCode;
          new_code = "";
          MessageBox.Show("Password changed.");
      }
      else
      {
          MessageBox.Show("You've entered an incorrect code. Please try again.");
      }
  }
  </code></pre>
  
  <p>Some of the code is in Dutch, so allow me to translate them.</p>
  
  <ul>
  <li>"Knop" means "Button".</li>
  <li>"Combinatie" --> "Combination".</li>
  <li>"Klaar" -->"Done".</li>
  <li>"Verander" --> "Change".</li>
  </ul>