Reputation: 764
I'm on windows phone 8 project. Doing it with xaml in visual studio.
I have 4 pivot items in this project.
I want to navigate the home page (my first pivot item) with
menu on bottom of phone;
<shell:ApplicationBarIconButton IconUri="Images/appbar_home.png" Text="Home" Click="ApplicationBarIconButton_Click_2"/>
and on click event i wrote this;
private void ApplicationBarIconButton_Click_2(object sender, EventArgs e)
{
NavigationService.Navigate(new Uri("/MainPage.xaml?PivotMain.SelectedIndex = 0", UriKind.Relative));
}
When i run the program, it works nice, when i go other pivot items, and click that home button, it goes, but if i walk around again and click button, it doesnt work. Why ?
I need to solve this.
Thanks for the answers.
Upvotes: 0
Views: 125
Reputation: 9865
You are having this problem because you are doing it wrong.
NavigationService.Navigate
is meant to navigate between XAML Files, not reload them. The phone doesn't like to reload the same page over and over.
What you want to do instead is set the current selected index to the first page.
It will look something like this
private void ApplicationBarIconButton_Click_2(object sender, EventArgs e)
{
PivotControlName.SelectedIndex = 0;
}
Upvotes: 1