0

Web サービスを含むコードと WindowsPhoneDataBound アプリケーションのコードをマージしたいのですが、可能ですか? そしてどうやって?私のコード:

   private void button1_Click(object sender, RoutedEventArgs e)
    {
        Uri url = new Uri("http://www.google.com/ig/api?weather=" + textBoxVille.Text, UriKind.Absolute);
        WebClient client = new WebClient();
        client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(client_DownloadStringCompleted);
        client.DownloadStringAsync(url);
    }
    void client_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
    {
        if (e.Error == null)
        {
            StringReader stream = new StringReader(e.Result);
            XmlReader reader = XmlReader.Create(stream);

            reader.MoveToContent();

            while (reader.Read())
            {
                switch (reader.Name)
                {
                    case ("day_of_week"):
                        {
                            listBox1.Items.Add(new ListBoxItem()
                            {
                                Content = reader.GetAttribute("data")
                            });
                        } break;
                    case ("low"):
                        {
                            listBox1.Items.Add(new ListBoxItem()
                            {
                                Content = reader.GetAttribute("data")
                            });
                        } break;
                    case ("high"):
                        {
                            listBox1.Items.Add(new ListBoxItem()
                            {
                                Content = reader.GetAttribute("data")
                            });
                        } break;
                    case ("icon"):
                        {
                            listBox1.Items.Add(new ListBoxItem()
                            {
                                Content = reader.GetAttribute("data")
                            });
                        } break;

                    case ("condition"):
                        {
                            listBox1.Items.Add(new ListBoxItem()
                            {
                                Content = reader.GetAttribute("data")
                            });
                        } break;
                    case ("weather"):
                        break;
                }
            }
            reader.Close();
        }
    }
4

1 に答える 1