程序改变Windows Phone 7应用程序启动页面。

时间:2022-12-15 22:39:56

I've created a simple bus time table application, which contains a favourites page, a search page and a results page. If the user has a favourite, then I'd like them to be shown the favourites page, otherwise they should be shown the search page. Also if the user has performed a search in the last 10 mins, then they should go to the results page.

我创建了一个简单的总线时间表应用程序,它包含一个最受欢迎的页面、一个搜索页面和一个结果页面。如果用户有一个最喜欢的页面,那么我希望他们显示最喜欢的页面,否则应该显示搜索页面。另外,如果用户在最后10分钟内进行了搜索,那么他们应该访问结果页面。

How I initially did this, was to call NavigationService.Navigate in the MainPage.xaml Loaded event. This seemed to work fine, but I failed Microsoft's validation due to the fact that the back button no longer exited the app (due to the hidden page still being in the navigation stack).

我最初的做法是叫NavigationService。在主页导航。xaml加载事件。这似乎没问题,但我失败了微软的验证,因为后退按钮不再退出应用程序(因为隐藏页面仍然在导航堆栈中)。

I then thought of having a Loaded property in my app, and if the user had already been redirected on login, then the App would either call Quit or GoBack, but neither option seems to be viable (there's no Quit, and calling GoBack on the first page will fail).

然后我想到在我的应用程序中有一个加载的属性,如果用户已经被重定向到登录,那么这个应用程序将会调用Quit或GoBack,但是这两个选项似乎都不可行(没有退出,在第一个页面调用GoBack将会失败)。

Does anyone know the best way to implement page redirections or clean up the navigation stack?

有没有人知道实现页面重定向的最佳方法,或者清理导航堆栈?

2 个解决方案

#1


1  

There are a number of ways to implement this kind of approach as documented by Peter Torr in his blog post Redirecting an initial navigation. In your circumstance, I think the custom UriMapper is probably the best solution.

有很多方法可以实现这种方法,正如Peter Torr在他的博客中所记录的,重新引导最初的导航。在您的情况下,我认为定制的UriMapper可能是最好的解决方案。

#2


0  

I would suggest always showing the main page to the user. The main page should allow access to favorites, searches and results. The user will choose the page they want. You may think you are doing the user favour by pre-loading what you think they want but for every 8 where you are correct there will be 2 that want another page. Plus you simplify the app and pass validation.

我建议总是向用户显示主页面。主页应该允许访问收藏夹、搜索和结果。用户将选择他们想要的页面。你可能认为你是通过预先加载你认为他们想要的东西来帮助用户,但是对于每8个你正确的地方,就会有2个想要另一个页面。此外,你还可以简化应用程序并通过验证。

#1


1  

There are a number of ways to implement this kind of approach as documented by Peter Torr in his blog post Redirecting an initial navigation. In your circumstance, I think the custom UriMapper is probably the best solution.

有很多方法可以实现这种方法,正如Peter Torr在他的博客中所记录的,重新引导最初的导航。在您的情况下,我认为定制的UriMapper可能是最好的解决方案。

#2


0  

I would suggest always showing the main page to the user. The main page should allow access to favorites, searches and results. The user will choose the page they want. You may think you are doing the user favour by pre-loading what you think they want but for every 8 where you are correct there will be 2 that want another page. Plus you simplify the app and pass validation.

我建议总是向用户显示主页面。主页应该允许访问收藏夹、搜索和结果。用户将选择他们想要的页面。你可能认为你是通过预先加载你认为他们想要的东西来帮助用户,但是对于每8个你正确的地方,就会有2个想要另一个页面。此外,你还可以简化应用程序并通过验证。