zoukankan      html  css  js  c++  java
  • wpf window镶嵌window,使用Frame实现

    最近项目中用到window镶嵌window功能,但是网上没有相关的资料,甚至很多人说没办法在window镶嵌window,后来我想到一个变通的方法,如下:

    前台source:

    <Window x:Class="WpfApplication1.MainWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            Title="MainWindow" Height="350" Width="525">
        <Grid>
            <Frame Height="150" HorizontalAlignment="Left" Margin="85,30,0,0" Name="frame1" VerticalAlignment="Top" Width="340" />
            <Button Content="Button" Height="23" HorizontalAlignment="Left" Margin="111,249,0,0" Name="button1" VerticalAlignment="Top" Width="75" Click="button1_Click" />
        </Grid>
    </Window>
    

     后天source:

    public partial class MainWindow : Window
        {
            public MainWindow()
            {
                InitializeComponent();
            }
    
            private void button1_Click(object sender, RoutedEventArgs e)
            {
                Window1 win = new Window1();
                this.frame1.Content = win.Content;
            }
        }
    

     虽然可以实现镶嵌window,但是只是获取window中的所有,放到Frame中,

    期待牛人有更好用的方法。

  • 相关阅读:
    建议自学
    大牛之术
    学习榜样
    .net源码
    练习题
    学习-如何克服拖延
    如何解决困难问题
    最近阅读
    如何学习一门新语言
    安全问题关注博客
  • 原文地址:https://www.cnblogs.com/lckblog/p/3402090.html
Copyright © 2011-2022 走看看