示例#1
0
        private void SearchOffline(object sender, RoutedEventArgs e)
        {
            var json = File.ReadAllText("BooksOffline.json");

            jsonTb.Text = json;

            BookResults bookResults = JsonConvert.DeserializeObject <BookResults>(json);

            bookListBox.ItemsSource = bookResults.items;
            booksCb.ItemsSource     = bookResults.items;

            myGrid.ItemsSource = bookResults.items.Select(x => x.volumeInfo);
        }
示例#2
0
        private async void Search(object sender, RoutedEventArgs e)
        {
            var url  = $"https://www.googleapis.com/books/v1/volumes?q={suchTb.Text}";
            var http = new HttpClient();
            var json = await http.GetStringAsync(url);

            jsonTb.Text = json;

            BookResults bookResults = JsonConvert.DeserializeObject <BookResults>(json);

            bookListBox.ItemsSource = bookResults.items;
            booksCb.ItemsSource     = bookResults.items;

            myGrid.ItemsSource = bookResults.items.Select(x => x.volumeInfo);
        }