Navigation in windows phone7

别来无恙 提交于 2020-01-06 18:01:30

问题


What kind of navigation is best suited for a home button in an application,Can any please help me,I am newbie?


回答1:


Updated Answer based on your comments, First you need to create a button(preferably an Appbar button) and then place this code in the click event handler

NavigationService.Navigate(new Uri("/Home.xaml?home=true", UriKind.Relative));

And then in the Home page in the onNavigatedTo event handler place this code

string home;
NavigationContext.QueryString.TryGetValue("home", out home);
if(home != null)
{
    if (home.Equals("true"))
        while(NavigationService.CanGoBack)
           NavigationService.RemoveBackEntry();
}

So this clears all your back stack

Note: This is not any preferable or recommended way, its just a workaround!!




回答2:


Add a button in every page (since you want to go home from every page) put the onClick to do:

NavigationService.Navigate("YoursView/HomePage.xaml", UriKind.RelativeOrAbsolute);



回答3:


You may want to review the following MSDN documentation regarding Application Structure and Navigation Models :-

http://msdn.microsoft.com/en-us/library/hh202909(v=vs.92).aspx




回答4:


This worked.

  1. Globally I declared a Boolean variable set to false in a class.

  2. Then whenever the home button is clicked bool variable is set as true and navigated back.

    Modules.HomeClick = true;
    NavigationService.GoBack();
    
  3. Then in every page for page loaded event I checked condition if bool variable true go back.

    if (Modules.HomeClick=true)
    this.NavigationService.GoBack();
    

these done in every page till homepage.This do not store backstack.



来源:https://stackoverflow.com/questions/11187944/navigation-in-windows-phone7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!