Advertisement
JAcob_007

SpacesXAMLPage

Feb 10th, 2017
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.07 KB | None | 0 0
  1. using System;
  2. using ParseJsonData.Models;
  3. using ParseJsonData.ViewModels;
  4. using System.Collections.ObjectModel;
  5. using Xamarin.Forms;
  6.  
  7. namespace ParseJsonData.Views
  8. {
  9.     public partial class SpacesXamlPage : ContentPage
  10.     {
  11.         private SpaceViewModel space_vm;
  12.         public ObservableCollection<Post> Posts { get; set; }
  13.  
  14.         public SpacesXamlPage()
  15.         {
  16.             InitializeComponent();
  17.             Posts = new ObservableCollection<Post>();
  18.             space_vm = new SpaceViewModel();
  19.             BindingContext = this;
  20.         }
  21.  
  22.         protected override async void OnAppearing()
  23.         {
  24.             base.OnAppearing();
  25.  
  26.             try
  27.             {
  28.                 var fetchedSpaces = await GetPostsAsync();
  29.  
  30.                 if (fetchedSpaces !=null)
  31.                 {
  32.                     foreach(var space in fetchedSpaces)
  33.                     {
  34.                         Spaces.Add(space);
  35.                     }
  36.                 }
  37.             }
  38.            catch (Exception ex)
  39.             {
  40.  
  41.             }
  42.         }
  43.     }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement