문제

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