【发布时间】:2014-11-13 02:13:25
【问题描述】:
我正在尝试使用 JSON 创建一个简单的 windows phone 8.1 应用程序。 我的问题是,从 ListView 中单击一个项目后,如何打开第二个页面,其中包含与所选项目相关的数据?
public MainPage()
{
this.InitializeComponent();
this.NavigationCacheMode = NavigationCacheMode.Required;
var client = new HttpClient();
var task = client.GetAsync("json")
.ContinueWith((taskwithresponse) =>
{
var response = taskwithresponse.Result;
var jsonString = response.Content.ReadAsStringAsync();
jsonString.Wait();
dynamic content = JsonConvert.DeserializeObject<RootObject>(jsonString.Result);
Dispatcher.RunAsync(CoreDispatcherPriority.Normal, new DispatchedHandler(() =>
{
List.ItemsSource = content.value.items;
})).AsTask().Wait();
});
}
private void listView_ItemClick(object sender, RoutedEventArgs e)
{
this.Frame.Navigate(typeof(SecondPage));
}
【问题讨论】:
标签: c# json xaml windows-phone-8.1