Robię sobie czytnik RSS z wykorzystaniem PIVOT. W Pivot Item One umieściłem wczytywanie tematów a w Pivot Item Two wczytywanie postów. Jednak zrobiłem to niepoprawnie bo wyskakuje błąd:
Type 'Mój Czytnik.ostatnie' already defines a member called 'OnNavigatedTo' with the same parameter types
i nie wiem jak to rozwiązać.
Kod połączyłem w ten sposób:
using System;
using System.Collections.Generic;
using System.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;
using System.IO;
using System.ServiceModel.Syndication;
using System.Xml;
using Microsoft.Phone.Tasks;
namespace Mój Czytnik
{
public partial class ostatnie : PhoneApplicationPage
{
public ostatnie()
{
InitializeComponent();
}
private void loadFeedButton_Click(object sender, System.Windows.RoutedEventArgs e)
{
WebClient webClient = new WebClient();
webClient.DownloadStringCompleted += new DownloadStringCompletedEventHandler(webClient_DownloadStringCompleted);
webClient.DownloadStringAsync(new System.Uri("http://adres1"));
webClient.Headers["Cache-Control"] = "no-cache";
}
private void webClient_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
if (e.Error != null)
{
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
MessageBox.Show("Próba wczytania danych zakończona niepowodzeniem, sprawdź połączenie z siecią.");
});
}
else
{
this.State["feed"] = e.Result;
UpdateFeedList(e.Result);
}
}
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
if (this.State.ContainsKey("feed"))
{
if (feedListBox.Items.Count == 0)
{
UpdateFeedList(State["feed"] as string);
}
}
}
private void UpdateFeedList(string feedXML)
{
// Load the feed into a SyndicationFeed instance
StringReader stringReader = new StringReader(feedXML);
XmlReader xmlReader = XmlReader.Create(stringReader);
SyndicationFeed feed = SyndicationFeed.Load(xmlReader);
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
feedListBox.ItemsSource = feed.Items;
loadFeedButton.Content = "Odśwież";
});
}
private void feedListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
ListBox listBox = sender as ListBox;
if (listBox != null && listBox.SelectedItem != null)
{
SyndicationItem sItem = (SyndicationItem)listBox.SelectedItem;
if (sItem.Links.Count > 0)
{
Uri uri = sItem.Links.FirstOrDefault().Uri;
WebBrowserTask webBrowserTask = new WebBrowserTask();
webBrowserTask.Uri = uri;
webBrowserTask.Show();
}
}
}
private void loadFeedButton2_Click(object sender, System.Windows.RoutedEventArgs e)
{
WebClient webClient2 = new WebClient();
webClient2.DownloadStringCompleted += new DownloadStringCompletedEventHandler(webClient2_DownloadStringCompleted);
webClient2.DownloadStringAsync(new System.Uri("http://adres2"));
webClient2.Headers["Cache-Control"] = "no-cache";
}
private void webClient2_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
if (e.Error != null)
{
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
MessageBox.Show("Próba wczytania danych zakończona niepowodzeniem, sprawdź połączenie z siecią.");
});
}
else
{
this.State["feed2"] = e.Result;
UpdateFeedList2(e.Result);
}
}
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e) // TUTAJ PODKREŚLA BŁĄD !
{
if (this.State.ContainsKey("feed2"))
{
if (feedListBox2.Items.Count == 0)
{
UpdateFeedList2(State["feed2"] as string);
}
}
}
private void UpdateFeedList2(string feedXML2)
{
// Load the feed into a SyndicationFeed instance
StringReader stringReader2 = new StringReader(feedXML2);
XmlReader xmlReader2 = XmlReader.Create(stringReader2);
SyndicationFeed feed2 = SyndicationFeed.Load(xmlReader2);
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
feedListBox2.ItemsSource = feed2.Items;
loadFeedButton2.Content = "Odśwież";
});
}
private void feedListBox2_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
ListBox listBox2 = sender as ListBox;
if (listBox2 != null && listBox2.SelectedItem != null)
{
SyndicationItem sItem2 = (SyndicationItem)listBox2.SelectedItem;
if (sItem2.Links.Count > 0)
{
Uri uri = sItem2.Links.FirstOrDefault().Uri;
WebBrowserTask webBrowser2Task = new WebBrowserTask();
webBrowser2Task.Uri = uri;
webBrowser2Task.Show();
}
}
}
}
}