简单的登录模块

重叠控件点击透过用HitTest属性做修改

xaml:IsHitTestVisible="False"

简答的登录模块:

        private void signIn_Click(object sender, RoutedEventArgs e)

        {

            int i = 0;

            string str = signIn.Content.ToString();

            if (textBox1.Text.ToString() == "" && str == "登陆")

            {

                System.Windows.Forms.MessageBox.Show("登陆错误");

                i = 0;

            }

            else

            {

                i =1;

                if (str == "登陆" && i == 1)

                {

                    textBox1.Visibility = Visibility.Hidden;

                    passwordBox1.Visibility = Visibility.Hidden;

                    textBlock2.Visibility = Visibility.Visible;

                    textBlock2.Text = "欢迎用户  "+textBox1.Text;

                    textBox1.Text = null;

                    signIn.Content = "退出";

                }

                else

                {

                    textBlock2.Text = null;

                    passwordBox1.Password = null;

                    textBox1.Visibility = Visibility.Visible;

                    passwordBox1.Visibility = Visibility.Visible;

                    textBlock2.Visibility = Visibility.Hidden;

                    textBlock2.Text = textBox1.Text;

                    signIn.Content = "登陆";



                }

            }



        }

你可能感兴趣的:(登录)