wpf--entity classes and binding entity class properties

Source: Internet
Author: User

  Public classUser:Private string_user;  Public stringUser1 {Get{return_user;} Set{_user=value; }        }              Private string_password;  Public stringPassword {Get{return_password;} Set{_password =value;} }               }    }
User u; Private voidButton_click_1 (Objectsender, RoutedEventArgs e)//Click the login button to pop up the new form        {            //first determine if the user name and password are correctU =NewUser (); U.user1="Admin"; U.password="123"; if(string. Isnullorwhitespace (TextBox1.Text))//determine if the value of the User name box is not empty{MessageBox.Show ("user name is empty"); }            Else            {                if(TextBox1.Text = = U.user1 && Textbox2.password = =U.password) {Window1 F=NewWindow1 (U);//You pass the entity class U to the form you just opened so that the form you just opened can call the entity class.f.show ();  This. Owner =F;  This.                Hide (); }                Else{MessageBox.Show ("The user name or password is incorrect"); }            }        }

The following click on the login, the input text to the new form, the method is to bind the entity class user, by binding the data inside the user to achieve the value of the pass.

The Binding property is Bindint User1 (User1 is the username attribute in the entity class user) Mode=default is the binding method

Then assign a value to two text boxes in the new form, and the content of the assignment is the contents of the attributes in the user of the bound entity class.

  Public Partial classWindow1:window {User U;//as with the previous transmission of the form, transfer variables, here is the entity class;         PublicWindow1 (User u) {initializecomponent (); U=u; //TextBox1.Text = u.user1 + "\ n" + U.password;//"\ n": Line breakTextbox1.datacontext = U;//the data source of the text box 1 is the entity class U, when you just drag into the text box 1, the text box 1 is bound to the user name (User1) attribute in the entity class userTextbox2.datacontext = U;//the data source of the text box 2 is the entity class U, when you just drag into the text box 2, the text box 2 is bound to the entity class User password (Password) attribute        }    }

wpf--entity classes and binding entity class properties

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.