【发布时间】:2018-06-01 16:50:21
【问题描述】:
我正在制作一个 UWP 应用程序,我在其中导航到带有列表视图的页面。 在构造函数中,我调用了一个异步函数来设置listview的itemsource。数据存储在本地,但这需要一些时间来过滤和排序列表。虽然我调用了一个异步函数,但在设置列表视图的 itemsource 之前不会发生导航。
public FriendsPage()
{
this.InitializeComponent();
RefreshListViews();
}
//I tried both these versions: in the first one,
//the app clearly takes one extra second to navigate to the page.
private async void RefreshListViews(){
await Task.Delay(1000);
Listview.ItemsSource = …;
}
private async void RefreshListViews(){
await Dispatcher.RunAsyn(Windows.UI.Core.CoreDispatcherPriority.Normal,() => {
Listview.ItemsSource = …;
});
}
我该如何解决这个问题,让应用首先导航,然后过滤/排序/填充列表视图?
【问题讨论】:
-
导航代码在哪里?
-
问题在于导航到此页面时。就是这样:rootFrame.Navigate(typeof(FriendsPage));在我的主页中。
标签: c# listview uwp navigation