页面导航事件
我正在阅读槽UWP的文档,我卡住了一下。页面导航事件
我有几个页面连接到WCF服务获取它的一些信息,其中几个下载图片,并需要几秒钟加载。
当我尝试使用
this.Frame.Navigate(typeof(page));
我就会陷入死锁状态一切,而新的页面加载,我试图把对冻结所以我决定来实现加载屏幕但同时它们的加载页面加载事件在其他页面上,但这并没有什么帮助,因为它仍然锁定在最后一页。
有没有人知道我需要调用this.Frame.Navigate()
时需要调用的正确事件,以便在新帧加载时初始化我的加载控件?
-
导航到加载屏幕
this.Frame.Navigate(typeof(LoadingScreen));
-
在LoadingScreen
OnNavigatedTo
事件 “图片下载”protected override async void OnNavigatedTo(NavigationEventArgs e) { await DownloadPictures(); //After downloading, navigate to the next page this.Frame.Navigate(typeof(page)); }
您的回答是正确的,但我不得不将它放在页面加载并隐藏控件,因为进度控件在导航时未初始化 –
尝试推出一个单独的窗口中的视图这样
try
{
CoreApplicationView Nv= CoreApplication.CreateNewView();
var z = CoreApplication.MainView;
int id= 0;
await
Nv.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal,() =>
{
Frame frame = new Frame();
frame.Navigate(typeof(page));
Window.Current.Content = frame;
// You have to activate the window in order to show it later.
Window.Current.Activate();
id= ApplicationView.GetForCurrentView().Id;
});
bool viewShown = await ApplicationViewSwitcher.TryShowAsStandaloneAsync(id);
}
catch (Exception eee)
{
Windows.UI.Popups.MessageDialog errorBox =
new Windows.UI.Popups.MessageDialog("Couldn't Create New
Window: " + eee.Message);
await errorBox.ShowAsync();
}
我的当前功能已经实现了此方法,但是我想从当前框架中找到一种方法来打开一个新窗口。 –
@KristiforMilchev你的问题帖子太抽象了,并没有提供足够的信息给任何人玩。 –
没有什么抽象的东西,我需要一个事件,在两帧之间的过渡时异步文件,就像你的答案,但避免打开一个新的框架。 –
你尝试过'OnNavigatedTo'事件吗? –
是的,它确实进入了内部,但也没有帮助,我也尝试过Navigate,OnNavigateFrom大多数。 –
“加载屏幕”是否会在转到实际页面之前导航的页面? –