Mini-Con
Mini-Con

Reputation: 397

Navigation in windows phone7

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

Upvotes: 0

Views: 168

Answers (4)

Mini-Con
Mini-Con

Reputation: 397

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.

Upvotes: 0

nkchandra
nkchandra

Reputation: 5557

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!!

Upvotes: 1

Paul Diston
Paul Diston

Reputation: 3294

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

Upvotes: 0

MBen
MBen

Reputation: 3996

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);

Upvotes: 0

Related Questions