zoukankan      html  css  js  c++  java
  • WPF页面切换及弹窗

    WPF页面切换及弹窗

    结构如图:

    效果如图:

    代码如下:

    xaml

     1 <Window x:Class="PageChange.MainWindow"
     2         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
     3         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
     4         Title="MainWindow" Height="350" Width="400">
     5     <Grid>
     6         <Grid.ColumnDefinitions>
     7             <ColumnDefinition Width="100"></ColumnDefinition>
     8             <ColumnDefinition Width="300"></ColumnDefinition>
     9         </Grid.ColumnDefinitions>
    10         <StackPanel Orientation="Vertical" Grid.Column="0">
    11             <Button Content="第一页" Name="tb1" Click="tb1_Click"></Button>
    12             <Button Content="第二页" Name="tb2" Click="tb2_Click"></Button>
    13             <Button Content="第三页" Name="tb3" Click="tb3_Click"></Button>
    14             <Button Content="弹窗" Name="tb4" Click="tb4_Click"></Button>
    15         </StackPanel>
    16         <Grid Grid.Column="1" Name="MyGrid" Height="300" Width="300"></Grid>
    17        
    18     </Grid>
    19 </Window>

    后置代码

     1 using System;
     2 using System.Collections.Generic;
     3 using System.Linq;
     4 using System.Text;
     5 using System.Threading.Tasks;
     6 using System.Windows;
     7 using System.Windows.Controls;
     8 using System.Windows.Data;
     9 using System.Windows.Documents;
    10 using System.Windows.Input;
    11 using System.Windows.Media;
    12 using System.Windows.Media.Imaging;
    13 using System.Windows.Navigation;
    14 using System.Windows.Shapes;
    15 
    16 namespace PageChange
    17 {
    18     /// <summary>
    19     /// MainWindow.xaml 的交互逻辑
    20     /// </summary>
    21     public partial class MainWindow : Window
    22     {
    23         public MainWindow()
    24         {
    25             InitializeComponent();
    26         }
    27 
    28         private void tb1_Click(object sender, RoutedEventArgs e)
    29         {
    30             MyGrid.Children.Add(new Page1());
    31         }
    32 
    33         private void tb2_Click(object sender, RoutedEventArgs e)
    34         {
    35             MyGrid.Children.Add(new Page2());
    36         }
    37 
    38         private void tb3_Click(object sender, RoutedEventArgs e)
    39         {
    40             MyGrid.Children.Add(new Page3());
    41         }
    42 
    43         private void tb4_Click(object sender, RoutedEventArgs e)
    44         {
    45             Window w = new Window();
    46             NewPage n = new NewPage();
    47             w.Content = n;
    48             w.ShowDialog();
    49         }
    50     }
    51 }
  • 相关阅读:
    gitblit 配置图文详解
    springmvc文件下载之文件名下划线问题终极解决方案
    redis实战进阶
    关于B+树, 你要了解的都在这里
    http的长连接和短连接(史上最通俗!)以及应用场景
    Base64的前世今生
    Springfox集成Swagger2实战篇
    Minio使用详解
    ubuntu系统五笔输入法安装
    YouTube排名第一的励志英文演讲《Dream(梦想)》
  • 原文地址:https://www.cnblogs.com/weiweiboqi/p/4673630.html
Copyright © 2011-2022 走看看