在 Windows Phone 8 上工作。
遇到了一个问题,几年前我以某种方式解决了,但不记得了。
GetNews();
InitializeComponent();
private void GetNews()
{
HttpWebRequest request = HttpWebRequest.CreateHttp(GS.BACKEND_HOST + "something");
request.BeginGetResponse(new AsyncCallback(HandleResponseNews), request);
}
private void HandleResponseNews(IAsyncResult result)
{
HttpWebRequest request = result.AsyncState as HttpWebRequest;
if (request != null)
{
using (WebResponse response = request.EndGetResponse(result))
{
using (StreamReader reader = new StreamReader(response.GetResponseStream()))
{
string JSON = reader.ReadToEnd();
NewsList = JsonConvert.DeserializeObject<News>(JSON) as News;
}
}
}
}
我需要用 NewsList 项目填充我的列表框。但我只能在 NewsList 充满请求响应后才能做到。
我需要某种类型的触发器...