I'm thing to navigate between pages while keeping the same original page

The Code in MainPage.xaml is

xmlns:views="clr-namespace:MainPage.View"

<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
      <views:Page1 x:Name="InterfacePage"/>
</Grid>

Page1 in a User Control Page with a button in it. When I press that button I would like to change Page1 to Page2 another User Control Page without changing the MainPage

I've been searching but can't find anything on this By the way I'm doing this using the windows Phone 8 sdk Thanks

有帮助吗?

解决方案

In the ButtonClick event of the Page1, try this

Button_Click()
{
    var contentPanel = (this.Parent as Grid);
    Page2 page2 = new Page2() { Name = "AnotherPage" };

    contentPanel.Children.Remove(this);
    contentPanel.Children.Add(page2);
}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top