C# 如何将web服务数据解析到windows phone 8.0 pivot app MainViewModel?

C# 如何将web服务数据解析到windows phone 8.0 pivot app MainViewModel?,c#,.net,windows-phone-8,httpclient,C#,.net,Windows Phone 8,Httpclient,我不熟悉C windows phone编程。 我有一个与windows phone 8.0中的pivot模板应用程序相关的问题 如何使用HttpClient数据配置Pivot模板应用程序 我有这个http请求,也可以得到响应。这个工作很好 public async static Task<List<MyData>> GetWebserviceData() { HttpClient = new HttpClient(); string respo

我不熟悉C windows phone编程。 我有一个与windows phone 8.0中的pivot模板应用程序相关的问题

如何使用HttpClient数据配置Pivot模板应用程序

我有这个http请求,也可以得到响应。这个工作很好

public async static Task<List<MyData>> GetWebserviceData()
{
       HttpClient = new HttpClient();
       string response = await client.GetStringAsync("http://xxxx/xxx/xxx");

       List<MyData> data = JsonConvert.DeserializeObject<List< MyData >>(response);

       return data;
}
我想将此数据解析为pivot app->MainViewModel->LoadData

    public class MainViewModel : INotifyPropertyChanged
        {
            public MainViewModel()
            {
                this.Items = new ObservableCollection<ItemViewModel>();
            }

            /// <summary>
            /// A collection for ItemViewModel objects.
            /// </summary>
            public ObservableCollection<ItemViewModel> Items { get; private set; }

            private string _sampleProperty = "Sample Runtime Property Value";
            /// <summary>
            /// Sample ViewModel property; this property is used in the view to display its value using a Binding
            /// </summary>
            /// <returns></returns>
            public string SampleProperty
            {
                get
                {
                    return _sampleProperty;
                }
                set
                {
                    if (value != _sampleProperty)
                    {
                        _sampleProperty = value;
                        NotifyPropertyChanged("SampleProperty");
                    }
                }
            }

            /// <summary>
            /// Sample property that returns a localized string
            /// </summary>
            public string LocalizedSampleProperty
            {
                get
                {
                    return AppResources.SampleProperty;
                }
            }



            /// <summary>
            /// Creates and adds a few ItemViewModel objects into the Items collection.
            /// </summary>
            public void LoadData()
            {
                // This Sample data; want to replace with real data which is return from GetWebserviceData()

                this.Items.Add(new ItemViewModel() { ID ="1", LineOne = "runtime one", LineTwo = "Maecenas praesent accumsan bibendum", LineThree = "Facilisi faucibus habitant inceptos interdum lobortis nascetur pharetra placerat pulvinar sagittis senectus sociosqu" });
                this.Items.Add(new ItemViewModel() { ID = "2", LineOne = "runtime two", LineTwo = "Dictumst eleifend facilisi faucibus", LineThree = "Suscipit torquent ultrices vehicula volutpat maecenas praesent accumsan bibendum dictumst eleifend facilisi faucibus" });


            }


        }
    }

有人能帮我吗。。谢谢你

按以下方式重写LoadData函数:

public async void LoadData()
{
    var response = await GetWebserviceData();
    foreach(var item in response)
    {
     this.Items.Add(item);
    }
}

亲爱的JGPhilip,是的,我试过了,它执行时没有错误,但数据没有绑定。只有UI正在加载,没有数据。可能的问题是什么?确保LoadData函数在上述页面的代码隐藏中等待。