美文网首页
WPF中的页面跳转

WPF中的页面跳转

作者: 北风知我意 | 来源:发表于2016-09-26 18:59 被阅读665次

    WPF页面跳转:

    WPF页面跳转有两种:一种是windows,另外一种是page

    1:windows页面跳转

    windows 页面跳转相信学过winform编程的哥们都知道,先实例化该窗体然后show一下就可以了.eg:有两个窗体Main和Login,要想点击Login 窗体上的注册按钮然后跳转到Main上,则在Login窗体的Click事件里代码如下:Main Mn=new Main();Mn.Show();

    2:Page页面跳转

    Page页面跳转:前台跳转和后台跳转都可以实现前台实现:

    Enter Page1

    后台实现:

    NavigationService.GetNavigationService(this).Navigate(newUri("Page1.xaml", UriKind.Relative));

    NavigationService.GetNavigationService(this).GoForward();//向后转

    NavigationService.GetNavigationService(this).GoBack();  //向前转

    在后台还可以这样写:this.content = new Page1();(这种比较简单,但是建议大家使用前一种更能提高自己,呵呵)

    另外还可以以实现windows跳转到page:

    NavigationWindow window =newNavigationWindow();

    window.Source =newUri("Page1.xaml", UriKind.Relative);

    window.Show();

    好文要顶关注我收藏该文

    JobinWang

    关注 - 4

    粉丝 - 6

    相关文章

      网友评论

          本文标题:WPF中的页面跳转

          本文链接:https://www.haomeiwen.com/subject/zliqyttx.html