SHOW:
|
|
- or go back to the newest paste.
1 | namespace AppUnno | |
2 | { | |
3 | public partial class MainPage : PhoneApplicationPage | |
4 | { | |
5 | public ObservableCollection<PopularVideos> PopVideos; | |
6 | int aux = 3; | |
7 | private List<Artista> _artistas; | |
8 | ||
9 | // Constructor | |
10 | public MainPage() | |
11 | { | |
12 | PopVideos = new ObservableCollection<PopularVideos>(); | |
13 | if (NetworkInterface.GetIsNetworkAvailable()) | |
14 | { | |
15 | // you are setting your DataContext below to 'App.ViewModel', | |
16 | //if you aren't using it, this is the DataContext you want: | |
17 | DataContext = this; | |
18 | InitializeComponent(); | |
19 | ConsultaArtista("http://www.unnu.com/music-artists"); | |
20 | //ConsultaPopularVideos("http://www.unnu.com/popular-music-videos"); | |
21 | panorama.Visibility = Visibility.Collapsed; | |
22 | - | |
22 | + | |
23 | - | // you are setting your DataContext to 'App.ViewModel', |
23 | + | // removed that line since using 'this'. |
24 | - | //if you aren't using it, do the following instead: |
24 | + | |
25 | - | DataContext = this; |
25 | + | |
26 | carregaFeed(); | |
27 | ApplicationBarra(aux); | |
28 | HtmlWeb.LoadAsync("http://www.unnu.com/popular-music-videos", DownLoadCompleted); | |
29 | } | |
30 | else | |
31 | { | |
32 | var result = MessageBox.Show("There are problems in your connection. Please verify your connection and try again!", "", MessageBoxButton.OK); | |
33 | aux = 1; | |
34 | ApplicationBarra(aux); | |
35 | } | |
36 | } | |
37 | private void DownLoadCompleted(object sender, HtmlDocumentLoadCompleted e) | |
38 | { | |
39 | PopVideos.Clear(); | |
40 | var data = e.Document.DocumentNode.SelectSingleNode("//div[@class='content']") | |
41 | .Descendants("img") | |
42 | .Select(img => new PopularVideos() | |
43 | { | |
44 | Titulo = img.Attributes["alt"].Value, | |
45 | Url = img.Attributes["src"].Value, | |
46 | }).ToList(); | |
47 | ||
48 | Deployment.Current.Dispatcher.BeginInvoke(() => | |
49 | { | |
50 | ||
51 | foreach (var item in data) | |
52 | { | |
53 | PopVideos.Add(new PopularVideos(item.Titulo, item.Url)); | |
54 | } | |
55 | }); | |
56 | } |