Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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 Newtonsoft.Json;
- using Microsoft.Phone.Reactive;
- namespace Cocktails
- {
- public partial class MainPage : PhoneApplicationPage
- {
- public string CocktailId { get; set; }
- // Constructor
- public MainPage()
- {
- InitializeComponent();
- var w = new WebClient();
- Observable
- .FromEvent<DownloadStringCompletedEventArgs>(w, "DownloadStringCompleted")
- .Subscribe(r =>
- {
- var deserialized =
- JsonConvert.DeserializeObject<List<Cocktails>>(r.EventArgs.Result);
- CocktailList.ItemsSource = deserialized;
- });
- w.DownloadStringAsync(
- new Uri("http://192.168.1.103/getdata.php"));
- }
- private void CocktailList_SelectionChanged(object sender, SelectionChangedEventArgs e)
- {
- //MessageBox.Show("Cocktail mit ID " + CocktailList.SelectedIndex);
- // If selected index is -1 (no selection) do nothing
- if (CocktailList.SelectedIndex == -1)
- return;
- // Navigate to the new page
- NavigationService.Navigate(new Uri("/DetailsPage.xaml?selectedItem=" + CocktailList.SelectedIndex, UriKind.Relative));
- // Reset selected index to -1 (no selection)
- CocktailList.SelectedIndex = -1;
- }
- }
- public class Cocktails
- {
- public string id { get; set; }
- public string name { get; set; }
- public string image { get; set; }
- public string description { get; set; }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment