WPF 中Frame + Page 的使用

1 在window 的设计的时候 ,中间需要进行页面切换的时候,顶一个Frame 

  1. <Frame Name="MainPage"  NavigationUIVisibility="Hidden" Grid.RowSpan="1"  Grid.Row="0"  ScrollViewer.CanContentScroll="False"   VerticalAlignment="Stretch" VerticalContentAlignment="Top">  
  2. </Frame>  


2 页面的跳转 

[csharp] view plain copy
  1. </pre><pre name="code" class="csharp">            MapPage page = new MapPage(this);  
  2.           //SystemPage page = new SystemPage(this);  
  3.             MainPage.Content = page;  


3 隐藏系统自带的前进,回退导航

  A . xmal 设置

  1. NavigationUIVisibility="Hidden"   


B C#代码设置 

[csharp] view plain copy
  1. MainPage.NavigationUIVisibility = System.Windows.Navigation.NavigationUIVisibility.Hidden;  


4   自定义按钮 ,实现前进和后退 

[csharp] view plain copy
    1. void back_btn_click(object sender, MouseEventArgs e)  
    2. {  
    3.     Console.WriteLine("点了back按钮!");  
    4.     if (page.NavigationService.CanGoBack)  
    5.    {  
    6.        page.NavigationService.GoBack();  
    7.    }  
    8. }  
    9.   
    10. void next_btn_click(object sender, MouseEventArgs e)  
    11. {  
    12.     Console.WriteLine("点了next按钮!");  
    13.     if (page.NavigationService.CanGoForward)  
    14.    {  
    15.        page.NavigationService.GoForward();  
    16.    }  
    17. 参考 http://blog.csdn.net/rually/article/details/47974005
原文地址:https://www.cnblogs.com/wenjieyatou/p/5619232.html