NavigationService.Navigate无法正常工作

时间:2012-11-29 13:56:23

标签: c# windows-phone-7

您好我是Windows Phone开发人员可能在编写代码时我做了一些尴尬的事情,我可以做像

这样的事情
button_click()
{
this.NavigationService.Navigate(new Uri("/HttpHandler.xaml", UriKind.Relative));
            WebHandler.Make_url_HandleResponse("someurl", 1);  
}

/*In HttpHandler Class having object Webhandler in previous class*/
     public void Make_url_HandleResponse(string Uri, int req_id)
        {
            try
            {
                uri = new Uri(Uri);
            }
            catch (Exception exception)
            {
                Debug.WriteLine(exception.Message);
                MessageBox.Show(exception.Message);
            }

       request = (HttpWebRequest)HttpWebRequest.Create(uri.AbsoluteUri);


            Debug.WriteLine("The url is" + uri);


        }



public void request_CallBack(IAsyncResult result)
    {
        try
        {
            //var request = (HttpWebRequest) result.AsyncState; 
            Stream stream;
            string ext_str;
            char[] separator = { '/' };

            HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(result);

            using (stream = response.GetResponseStream())
            {

               /* here I want to navigate to a new page*/
                    Deployment.Current.Dispatcher.BeginInvoke(delegate()
                    {
                        try
                        {
                             downloadingProgress.IsIndeterminate = false;
                             downloadingProgress.Visibility = Visibility.Collapsed;
                            stkDownloading.Visibility = Visibility.Collapsed;
                            this.NavigationService.Navigate(new Uri("/NewUser.xaml",UriKind.Relative));
                            }
                            catch (Exception e)
                            { }
                        }); 
    }

我试图询问是否可以从httphandler页面导航到另一个页面。提前谢谢

1 个答案:

答案 0 :(得分:0)

确保两个页面的命名空间相同(源和目标页面),否则你必须提到uri字符串中的路径。导航到另一个屏幕的代码是相同的:

NavigationService.Navigate(new Uri(“/ pageNmae.xaml”,UriKind.Relative));