WPF 中Frame + Page 的使用

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

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

2 页面的跳转 

</pre><pre name="code" class="csharp">            MapPage page = new MapPage(this);
          //SystemPage page = new SystemPage(this);
            MainPage.Content = page;


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

  A . xmal 设置

  NavigationUIVisibility="Hidden" 

B C#代码设置 

MainPage.NavigationUIVisibility = System.Windows.Navigation.NavigationUIVisibility.Hidden;

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

        void back_btn_click(object sender, MouseEventArgs e)
        {
            Console.WriteLine("点了back按钮!");
            if (page.NavigationService.CanGoBack)
           {
               page.NavigationService.GoBack();
           }
        }

        void next_btn_click(object sender, MouseEventArgs e)
        {
            Console.WriteLine("点了next按钮!");
            if (page.NavigationService.CanGoForward)
           {
               page.NavigationService.GoForward();
           }
        }



你可能感兴趣的:(C#,WPF)