将Windows 7手机模拟器连接到自己的网站?

时间:2010-11-02 02:22:35

标签: c# .net windows-phone-7

马库斯在这里。我遇到了一个难以解决的问题。显然,我有一个连接到dotnetzonereader的Windows 7手机编码的例子。好吧,我尝试将网址更改为www.google.com,但无法这样做。在这里,我不是指访问www.google.com的Windows 7模拟器中的Internet Explorer,但我说的是访问互联网的应用程序。这是我从网上获得的代码示例。我尝试更改此部分> dzoneRss.DownloadStringAsync(new Uri(“http://feeds.dzone.com/zones/dotnet”)); to dzoneRss.DownloadStringAsync(new Uri(“http://google.com”)); 但仍有错误。任何善良的灵魂来帮助我这个T_T。谢谢大家。真的谢谢你

using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;



namespace DotNetZoneReader
{
    public partial class MainPage : PhoneApplicationPage
    {
        public MainPage()
        {
            InitializeComponent();

            SupportedOrientations = SupportedPageOrientation.Portrait | SupportedPageOrientation.Landscape;
        }

        private void listBox1_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {

        }

        private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
        {

        }

        private void storyList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {

        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            var dzoneRss = new WebClient();
            dzoneRss.DownloadStringCompleted += dzoneRss_DownloadStringCompleted;
            dzoneRss.DownloadStringAsync(new Uri("http://feeds.dzone.com/zones/dotnet"));
        }
        private void dzoneRss_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
        {
            if (e.Error != null) return;
            XElement xmlStories = XElement.Parse(e.Result);
            XNamespace dz = "http://www.developerzone.com/modules/dz/1.0";
            storyList.ItemsSource = from story in xmlStories.Descendants("item")
                                    select new FeedItem
                                    {
                                        Title = story.Element("title").Value,
                                        Description = story.Element("description").Value,
                                        Link = story.Element("link").Value,
                                        PublishDate = Convert.ToDateTime(story.Element(dz + "submitDate").Value).ToString("dd-MMM"),
                                        Author = story.Element(dz + "submitter").Element(dz + "username").Value,
                                        AuthorImageUrl = story.Element(dz + "submitter").Element(dz + "userimage").Value
                                    };
        }
        public class FeedItem
        {
            public string Title { get; set; }
            public string Description { get; set; }
            public string Link { get; set; }
            public string PublishDate { get; set; }
            public string Author { get; set; }
            public string AuthorImageUrl { get; set; }
        }
    }
}

1 个答案:

答案 0 :(得分:0)

要访问谷歌,您可以通过在页面上放置一个WebBrowser控件并在WebBrowser加载的事件中将Source设置为指向google来完成此操作。 e.g。

    private void webBrowser1_Loaded(object sender, RoutedEventArgs e) {
        webBrowser1.Navigate(new Uri("http://www.google.com/", UriKind.Absolute));
    }

您链接的代码会根据您的要求执行不同的操作,但您不一定与Google的网站兼容。

您可以在空的Windows Phone应用程序项目中完成上述操作。