1

嗨,我是 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 页面导航到另一个页面。提前致谢

4

1 回答 1

0

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

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

于 2012-11-29T16:53:37.230 回答