如何从非派生的Phone应用程序页面进行页面导航Windows Phone 8



我是Windows Phone 8开发的新手。我正在尝试从我的 AzureFunctions 类导航到另一个页面,但我总是收到此错误

对象引用未设置为对象的实例。

我已经用谷歌搜索过,但仍然找不到任何解决方案。你们知道如何实现这一目标吗?

My RegisterPage(我在 AzureFunctions 类中调用 InsertData 方法)

private void signUp_button_Click(object sender, RoutedEventArgs e)
    {
        if (email_validation && password_validation && confirmPassword_validation == true)
        {
            new AzureFunctions().InsertData(new UserInfo_Table_Azure()
            {
                Email = regisEmail_textBox.Text,
                Password = regisPassword_textBox.Password,
                DOB = (DateTime)DOB_picker.Value,
                UserCancerInfo = (Boolean)userCancerInfo_checkBox.IsChecked,
                FamilyCancerInfo = (Boolean)userFamilyCancerInfo_checkBox.IsChecked
            });
        }
        else
        {
            String errorMsg = "";
            if (email_validation == false)
            {
                errorMsg += "Your email is not validrn";
                regisEmail_textBox.BorderBrush = new SolidColorBrush(Colors.Red);
            }
            if (password_validation == false)
            {
                errorMsg += "Your password can't be emptyrn";
                regisPassword_textBox.BorderBrush = new SolidColorBrush(Colors.Red);
            }
            if (confirmPassword_validation == false)
            {
                errorMsg += "Your Confirm password and password aren't matched";
                comfirmPassword_textBox.BorderBrush = new SolidColorBrush(Colors.Red);
            }
            MessageBox.Show(errorMsg);
        }
    }

My AzureFunctions Class

public async void InsertData(object data)
    {
        try
        {
            SystemFunctions.SetProgressIndicatorProperties(true);
            SystemTray.ProgressIndicator.Text = "Registering...";
            //Check type of data
            if (IsUserInfo_Data(data))
            {
                //Insert data into UserInfo_Table
                await azure_userInfo_table.InsertAsync((UserInfo_Table_Azure)data);
                Debug.WriteLine("Success inserting data to azure");
                SystemFunctions.SetProgressIndicatorProperties(false);
                MessageBoxResult result = MessageBox.Show(AppResources.RegisterSuccessfully, AppResources.Congratulation, MessageBoxButton.OK);
                if (result == MessageBoxResult.OK)
                {
                    try
                    {
                        new RegisterPage().NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
                    }
                    catch (NullReferenceException e)
                    {
                        Debug.WriteLine(e.Message);
                    }
                }
            }
            else if (IsPoop_Data(data))
            {
                //Insert data into Poop_Table
                await azure_poop_table.InsertAsync((Poop_Table_Azure)data);
                Debug.WriteLine("Success");
            }
        }
        catch (MobileServiceInvalidOperationException e)
        {
            SystemFunctions.SetProgressIndicatorProperties(false);
            Debug.WriteLine("Failed: " + e.Message);
        }
    }

从非页面进行导航并不是一个好主意,但这应该有效

App.RootFrame.Navigate(...)

相关内容

  • 没有找到相关文章

最新更新