最近项目中用到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中,

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

相关文章:

  • 2021-12-01
  • 2021-09-26
  • 2022-02-22
  • 2021-09-13
  • 2021-10-13
  • 2022-12-23
  • 2021-05-16
猜你喜欢
  • 2021-12-26
  • 2021-07-15
  • 2021-08-06
  • 2022-12-23
  • 2021-08-01
  • 2021-09-19
相关资源
相似解决方案