C# 在c中删除嵌套类时发生异常#

C# 在c中删除嵌套类时发生异常#,c#,windows-phone-8,C#,Windows Phone 8,当我执行程序时,我在构造函数中得到异常 例外是 System.Windows.ni.dll中首次出现类型为“System.Windows.Markup.XamlParseException”的异常 其他信息:未能分配到属性“System.Windows.Controls.TextBox.TextChanged”。[行:56位置:161] 在您的xaml文件中声明了一个textbox,该文件已分配给textchange事件。请查看该文件并删除分配给您的textbox的任何不需要的事件 乙二醇

当我执行程序时,我在构造函数中得到异常

例外是

System.Windows.ni.dll中首次出现类型为“System.Windows.Markup.XamlParseException”的异常

其他信息:未能分配到属性“System.Windows.Controls.TextBox.TextChanged”。[行:56位置:161]


在您的xaml文件中声明了一个textbox,该文件已分配给textchange事件。请查看该文件并删除分配给您的textbox的任何不需要的事件

乙二醇



如果需要,请删除文本更改事件,然后向代码隐藏中添加相同的事件名称,希望这能解决您的问题

是否查看了InitializeComponent()中的代码?能否向我们展示xaml?如何触发验证?检查其他分部类(InitializeComponent()实现所在的位置)查看异常发生的位置。它应该在MainPage.Designer.cs或类似的文件中。@qamar我已经更新了触发该类的函数。帮我触发课堂
namespace vali2
{
public partial class MainPage : PhoneApplicationPage
{

      public MainPage()
    {
        InitializeComponent(); //I get exception here


    }

    class validate: MainPage
    {
         int in_correct = 0, text_length = 10, phone_length = 10, correct = 0;
                string firstname_error = "Please enter a valid first name";
                string lastname_error = "Please enter a valid last name";
                string firstnmeln_error = "First name should be less than 10 letters";
                string lastnmeln_error = "Last name should be less than 10 letters";
                string gender_error = "Please select your gender";
                string contact_error = "Your phone number should contain only numbers";
                string contactln_error = "Your contact should contain 10 digits";
                string email_error = "Please enter a valid mail address";


         public void validatefn()
          {
               int Txtlen = ln.Text.Length;

                if (String.IsNullOrEmpty(ln.Text) || ln.Text.Any(c => Char.IsNumber(c)))
                    {
                        MessageBox.Show(firstname_error);
                        in_correct = 1;
                    }
               else if (Txtlen > text_length)
                    {
                        MessageBox.Show(firstnmeln_error);
                        in_correct = 1;
                    }
                else
                      correct = 1;
                       ln.Focus();
         }
        public void validateln()
        {      
            int Txtlen1 = dob.Text.Length;
            if (String.IsNullOrEmpty(ln.Text) || ln.Text.Any(c => Char.IsNumber(c)))
                {
                    MessageBox.Show(lastname_error);
                    in_correct = 1;

                }
            else if (Txtlen1 > text_length)
                {
                    MessageBox.Show(lastnmeln_error);
                    in_correct = 1;
                }
            else
                 correct = 1;
                 dob.Focus();
         }

        public void validategender()
        {

            if (male.IsChecked == false && female.IsChecked == false)
            {
                MessageBox.Show(gender_error);
                in_correct = 1;
            }

            correct = 1;
        }
        public void validatecontact()
        {
            Regex regex = new Regex("^[0-9]*$");
            int Txtlen3 = contact.Text.Length;
            if (!regex.IsMatch(contact.Text))
            {
                MessageBox.Show(contact_error);
                in_correct = 1;
            }
            else if (Txtlen3 != phone_length)
            {
                MessageBox.Show(contactln_error);
                in_correct = 1;
            }
            else
                correct = 1;
            contact.Focus();
        }

         public void validate_email()
         {
             Regex pattern = new Regex("^([0-9a-zA-Z]([-\\.\\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\\w]*[0-9a-zA-Z]\\.)+[a-zA-Z]{2,9})$");

            if (!pattern.IsMatch(email.Text))
            {
                MessageBox.Show(email_error);
                in_correct = 1;
            }
            else
                correct = 1;

            email.Focus();
         }


        //   if ((String.IsNullOrEmpty(ln.Text) || ln.Text.Any(c => Char.IsNumber(c)) && Txtlen > 10 )&& 
        //            (male.IsChecked == true || female.IsChecked == true) && (regex.IsMatch(contact.Text) && Txtlen3 < 10) && pattern.IsMatch(email.Text))

        public void iso()
        {
            IsolatedStorageSettings Setting = IsolatedStorageSettings.ApplicationSettings;
            Setting["text1"] = ln.Text;
            Setting["text2"] = dob.Text;
            Setting["text3"] = contact.Text;
            Setting["text4"] = email.Text;


            if (correct == 1 && in_correct == 0)
            {
                NavigationService.Navigate(new Uri("/Page1.xaml", UriKind.Relative));
            }


        }
 }
    public void save_Click(object sender, RoutedEventArgs e)
    {
        validate vali = new validate();
        vali.validatefn();
        vali.validateln();
        vali.validategender();
        vali.validatecontact();
        vali.validate_email();
        vali.iso();
    }
<TextBox x:Name="xyz" TextChanged="something here remove this event if not using"  Text=""/>