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; }
}
}
}
答案 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应用程序项目中完成上述操作。