Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace AppUnno
- {
- public partial class MainPage : PhoneApplicationPage
- {
- public ObservableCollection<PopularVideos> PopVideos;
- int aux = 3;
- private List<Artista> _artistas;
- // Constructor
- public MainPage()
- {
- PopVideos = new ObservableCollection<PopularVideos>();
- if (NetworkInterface.GetIsNetworkAvailable())
- {
- // you are setting your DataContext below to 'App.ViewModel',
- //if you aren't using it, this is the DataContext you want:
- DataContext = this;
- InitializeComponent();
- ConsultaArtista("http://www.unnu.com/music-artists");
- //ConsultaPopularVideos("http://www.unnu.com/popular-music-videos");
- panorama.Visibility = Visibility.Collapsed;
- // Set the data context of the listbox control to the sample data
- // removed that line since using 'this'.
- //DataContext = App.ViewModel;
- this.Loaded += new RoutedEventHandler(MainPage_Loaded);
- carregaFeed();
- ApplicationBarra(aux);
- HtmlWeb.LoadAsync("http://www.unnu.com/popular-music-videos", DownLoadCompleted);
- }
- else
- {
- var result = MessageBox.Show("There are problems in your connection. Please verify your connection and try again!", "", MessageBoxButton.OK);
- aux = 1;
- ApplicationBarra(aux);
- }
- }
- private void DownLoadCompleted(object sender, HtmlDocumentLoadCompleted e)
- {
- PopVideos.Clear();
- var data = e.Document.DocumentNode.SelectSingleNode("//div[@class='content']")
- .Descendants("img")
- .Select(img => new PopularVideos()
- {
- Titulo = img.Attributes["alt"].Value,
- Url = img.Attributes["src"].Value,
- }).ToList();
- Deployment.Current.Dispatcher.BeginInvoke(() =>
- {
- foreach (var item in data)
- {
- PopVideos.Add(new PopularVideos(item.Titulo, item.Url));
- }
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement