一步一步学Silverlight :综合实例之RSS阅读器
[1] 一步一步学Silverlight :综合实例之RSS阅读器
[2] 一步一步学Silverlight :综合实例之RSS阅读器
[3] 一步一步学Silverlight :综合实例之RSS阅读器
[2] 一步一步学Silverlight :综合实例之RSS阅读器
[3] 一步一步学Silverlight :综合实例之RSS阅读器
实现功能
下面实现数据的获取,采用WebRequest来实现,也可以使用其他方式。
/// <summary> /// 显示列表 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void displayButton_Click(object sender, RoutedEventArgs e) { Uri uri = new Uri(feedAddress.Text); WebRequest request = (WebRequest)WebRequest.Create(uri); request.BeginGetResponse(new AsyncCallback(responseReady), request); } void responseReady(IAsyncResult asyncResult) { WebRequest request = (WebRequest)asyncResult.AsyncState; WebResponse response = (WebResponse)request.EndGetResponse(asyncResult); XmlReader reader = XmlReader.Create(response.GetResponseStream()); SyndicationFeed feed = SyndicationFeed.Load(reader); PostsList.ItemsSource = feed.Items; }
显示详细信息:
/// <summary> /// 查看详细信息 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void PostsList_SelectionChanged(object sender, SelectionChangedEventArgs e) { SyndicationItem item = PostsList.SelectedItem as SyndicationItem; Detail.DataContext = item; }
实现全屏按钮的代码:
/// <summary> /// 全屏显示 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void fullScreenButton_Click(object sender, RoutedEventArgs e) { Content contentObject = Application.Current.Host.Content; contentObject.IsFullScreen = !contentObject.IsFullScreen; }