WPF页面切换及弹窗

结构如图:

效果如图:

代码如下:

xaml

 <Window x:Class="PageChange.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="" Width="">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width=""></ColumnDefinition>
<ColumnDefinition Width=""></ColumnDefinition>
</Grid.ColumnDefinitions>
<StackPanel Orientation="Vertical" Grid.Column="">
<Button Content="第一页" Name="tb1" Click="tb1_Click"></Button>
<Button Content="第二页" Name="tb2" Click="tb2_Click"></Button>
<Button Content="第三页" Name="tb3" Click="tb3_Click"></Button>
<Button Content="弹窗" Name="tb4" Click="tb4_Click"></Button>
</StackPanel>
<Grid Grid.Column="" Name="MyGrid" Height="" Width=""></Grid> </Grid>
</Window>

后置代码

 using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
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 PageChange
{
/// <summary>
/// MainWindow.xaml 的交互逻辑
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
} private void tb1_Click(object sender, RoutedEventArgs e)
{
MyGrid.Children.Add(new Page1());
} private void tb2_Click(object sender, RoutedEventArgs e)
{
MyGrid.Children.Add(new Page2());
} private void tb3_Click(object sender, RoutedEventArgs e)
{
MyGrid.Children.Add(new Page3());
} private void tb4_Click(object sender, RoutedEventArgs e)
{
Window w = new Window();
NewPage n = new NewPage();
w.Content = n;
w.ShowDialog();
}
}
}

WPF页面切换及弹窗的更多相关文章

  1. WPF 页面切换效果

    原文:WPF 页面切换效果 最近做一个有页面切换的吧.. 我觉得这个功能是比较基础的吧.. 在网上百度了一下.. 用NavigationWindow的比较好.. 因为Demo中是带了淡入淡出的页面效果 ...

  2. WPF页面切换

    XAML <Window x:Class="WpfApplication1.MainWindow" xmlns="http://schemas.microsoft. ...

  3. WPF中窗体在同一个位置实现不同页面切换

    要想在WPF窗体中实现不同页面切换,我们就需要用到ContentControl这个控件,这个控件的位置和大小就是你要显示页面的位置和大小. 下面举例说明: Xaml: <Grid> < ...

  4. 快速构建H5单页面切换骨架

    在Web App和Hybrid App横行的时代,为了拥有更好的用户体验,单页面应用顺势而生,单页面应用简称`SPA`,即Single Page Application,就是只有一个HTML页面的应用 ...

  5. Android中使用ViewPager实现屏幕页面切换和页面切换效果

    之前关于如何实现屏幕页面切换,写过一篇博文<Android中使用ViewFlipper实现屏幕切换>,相比ViewFlipper,ViewPager更适用复杂的视图切换,而且Viewpag ...

  6. ViewPager之Fragment页面切换

    一.概述 ViewPager是android-support-v4中提供的类,它是一个容器类,常用于页面之间的切换. 继上篇文章<ViewPager之引导页>之后,本文主要介绍ViewPa ...

  7. html tab页面切换事件。

    $(document).bind("visibilitychange",function(e){ //只对tab页面切换有效 //document.visibilityState ...

  8. vue-lazy-render: 延迟渲染大组件,增强页面切换流畅度

    最近用element来做项目,在开发的过程中,突然发现页面的操作和切换在数据量大的时候相当卡,后来提了个issue,在furybean解答后才知道,我每个单元格都加了tooltip,会生成大量的节点, ...

  9. 第54课 Qt 中的多页面切换组件

    1. 多页面切换组件(QTabWidget) (1)能够在同一个窗口中自由切换不同页面的内容 (2)是一个容器类型的组件,同时提供友好的页面切换方式 2. QTabWidget的使用方式 (1)在应用 ...

随机推荐

  1. art.dialog

    关闭指定弹出窗: art.dialog({ id: 'hetong' }).close(); 关闭所有的iframe弹出窗,art.dia.close();

  2. [置顶] 【VB.NET2010】注册表写入方法

    这里,以添加启动项为例: Imports Microsoft.Win32 Imports System.Reflection.Assembly   Private Sub SetAuto_Click( ...

  3. java 图片 批量 压缩 +所有压缩

    /* oldsrc  : 原图片地址目录 如 'd:/'    newsrc  : 压缩后图片地址目录 如 'e:/'    widthdist,heightdist : 压缩后的宽和高       ...

  4. AIX 常用命令和知识

      BOOTLIST:#bootlist -m normal -o (查看bootlist)#bootlist -m normal (设置bootlist为空,谁要在我机器上执行我就要哭了)#boot ...

  5. js_day13

  6. 安卓状态栏通知Status Bar Notification

    安卓系统通知用户三种方式: 1.Toast Notification 2.Dialog Notification 3.Status Bar Notification Status Bar Notifi ...

  7. 《第一行代码》学习笔记29-内容提供器Content Provider(2)

    1.查询操作: if (cursor != null) { while (cusor.moveToNext()) { String column1 = cursor.getString(cursor. ...

  8. oracle学习笔记(一)用户管理

    --oracle学习第一天 --连接 @后面连接数据库实例,具体连接到那个数据库 conn scott/tiger@MYORA1; --修改密码 passw; --显示用户 show user; -- ...

  9. XML配置silverlight ,wcf 解析xml

    XML 代码: <?xml version="1.0" encoding="utf-8" ?><ChartSet  xmlns:xsi=&qu ...

  10. onsubmit提交前先验证(验证不通过阻止form提交)

    <form  onsubmit = "return val();"> <input type="submit" value="提交& ...