I want, when we entered the password (correct), we stomped on, and if not the correct Label became visible. It would say: "The password is incorrect." On Windows Forms, everything was easier. I entered the password through the code, and then compared it with the written one ...

How to do it on WPF?

On WindowsForms, I did it like this:

string a = "123"; if (textBox1.Text == a) {

}

  • 3
    Just did not try? - Andrew NOP
  • Does not work! VS scolds me for writing textbox1 or TextBox ... I can’t do anything about it - Danil Bayramgaleev pm
  • Well, give the control a name in the markup, such as Name="TextBox1" and then call it by that name - Andrey NOP
  • That is, just write just public MainWindow () {InitializeComponent (); Name = "Textbox1"} - Danil Bayramgaleev
  • one
    It turned out! Thank you! - Danil Bayramgaleev

1 answer 1

If you do not care that the password in clear text will be stored inside the application, and anyone who knows how the startup files are organized will immediately find it, you can do this:

  <TextBox x:Name="textBox1" /> 

And check the page code as before. Where about InitializeComponent written.