Advertisement
Guest User

DrawnsView

a guest
Apr 1st, 2015
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.95 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Collections.ObjectModel;
  4.  
  5.  
  6. using Xamarin.Forms;
  7.  
  8. namespace EuroMillions
  9. {
  10.     public partial class DrawnsView : ContentPage
  11.     {
  12.         private APIReader api;
  13.         public DrawnsView ()
  14.         {
  15.             InitializeComponent ();
  16.             Drawns = new ObservableCollection<Drawn> ();
  17.             api = new APIReader ();
  18.             api.getLastDrawnASync ();
  19.             BindingContext = this;
  20.         }
  21.  
  22.         public ObservableCollection<Drawn> Drawns {
  23.             get;
  24.             set;
  25.         }
  26.  
  27.         protected override void OnAppearing()
  28.         {
  29.             base.OnAppearing();
  30.             if (Drawns.Count == 0)
  31.             {
  32.                 var drawns = api.getDrawns();
  33.                 foreach (var drawn in drawns)
  34.                 {
  35.                     Drawns.Add(drawn);
  36.                 }
  37.             }
  38.                                  
  39.         }
  40.  
  41.         private void DrawnsList_OnItemSelected(object sender, SelectedItemChangedEventArgs e)
  42.         {
  43.             if (LastDrawns.SelectedItem == null)
  44.             {
  45.                 return;
  46.             }
  47.  
  48.             LastDrawns.SelectedItem = null;
  49.         }
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement