[英]Windows phone update listview
I created a Windows phone 8.1 application with a listview on Startpage.xaml. 我在Startpage.xaml上创建了一个带有listview的Windows Phone 8.1应用程序。 When I update listview values, I don't see the changes on the phone until I close and open the application again. 当我更新listview值时,在我关闭并再次打开应用程序之前,我看不到手机上的更改。 I tried to update the listview when I clicked the refresh button, but unsuccessfully. 我单击刷新按钮时尝试更新列表视图,但未成功。 Anyone know how to update a listview when I click the refresh button? 当我点击刷新按钮时,任何人都知道如何更新列表视图?
How I fill in data in the listview: 我如何在listview中填写数据:
protected async override void OnNavigatedTo(NavigationEventArgs e)
{
this.navigationHelper.OnNavigatedTo(e);
HttpClient http = new HttpClient();
string str = ((ComboBoxItem)cbox.SelectedItem).Content.ToString();
var response = await http.GetStringAsync("http://mywebpage.si/events/apis/facebook_events.php?city=" + str + "&user=" + uporabnik.user);
var FSfeed = JsonConvert.DeserializeObject<List<Class1>>(response);
Reviews.ItemsSource = FSfeed;
}
My class: 我的课:
public class Class1
{
public string title { get; set; }
public string description { get; set; }
public string image { get; set; }
public string start { get; set; }
public string end { get; set; }
public string location { get; set; }
public string city { get; set; }
public int id { get; set; }
}
Refresh button: 刷新按钮:
private async void refresh_Click(object sender, RoutedEventArgs e)
{
HttpClient http = new HttpClient();
string str = ((ComboBoxItem)cbox.SelectedItem).Content.ToString();
var response = await http.GetStringAsync("http://mywebpage.si/events/apis/facebook_events.php?city=" + str + "&user=" + uporabnik.user);
var FSfeed = JsonConvert.DeserializeObject<List<Class1>>(response);
Reviews.ItemsSource = FSfeed;
}
I also tried to refresh like this, but unsuccessfully: 我也尝试像这样刷新,但没有成功:
private async void refresh_Click(object sender, RoutedEventArgs e)
{
this.Frame.Navigate(typeof(PivotPage));
}
To update the view you need to update the binding to ItemSource: 要更新视图,您需要更新对ItemSource的绑定:
List<Class1> mySource = new List<Class1>();
Binding binding = new Binding { Source = mySource };
BindingOperations.SetBinding(myListView, Windows.UI.Xaml.Controls.ListView.ItemsSourceProperty, binding);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.