【asp.net core】asp.net中wpf实现page跳转页面

更新时间:2019-07-11    来源:WPF    手机版     字体:

【www.bbyears.com--WPF】

在wpf项目中,经常遇到需要跳转窗口的功能,在以前分享一篇了

今天在分享一段代码,是通过content进行页面跳转的,这个和web的跳转就一点都不一样了。

界面:

IT分享wpf教程-page跳转页面

点击menu1 和2都会跳转到Page1.xaml和 Page2.xaml

IT分享wpf教程-page跳转页面
前台xaml:

 代码如下

        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">
   
       
           
       
            Menu1
       

            
       

       
       
            Menu2
       

       

       

        <frame Name="pc" Width="340" HorizontalAlignment="Right">
        </frame>
   

后台代码跳转:

 代码如下

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace WpfApplication3
{
    ///


    /// MainWindow.xaml 的交互逻辑
    ///

    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            pc.NavigationUIVisibility = NavigationUIVisibility.Hidden;
        }
        private void LnkPre1_Click(object sender, RoutedEventArgs e)
        {
            Page2 p2 = new Page2();
            pc.Content = p2;
        }
        private void LnkPre_Click(object sender, RoutedEventArgs e)
        {
            Page1 p1 = new Page1();
            pc.Content = p1;
        }
    }
}

本文来源:http://www.bbyears.com/asp/57510.html