在一个窗口中显示两个WPF窗口

时间:2019-05-13 08:15:06

标签: wpf multiple-views

我有一个作业,必须在同一WPF窗口的两个不同窗口中显示同一类的两个实例。有什么办法可以做到这一点?我是WPF的新手,因此很难处理。如何设计GUI部件,使用哪个面板以及如何在后台代码中将类分配给相应的窗口。

我尝试过使用DockPanel,代码在下面

<Window x:Class="Layout"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"                                       
        mc:Ignorable="d"
        Title="Layout" Height="450" Width="800">
    <Grid x:Name="grd_main">

        <DockPanel x:Name="dockpanel1"  HorizontalAlignment="Left" Height="194" LastChildFill="False" Margin="10,10,0,0" VerticalAlignment="Top" Width="772">
            <Window Name="windows1">
            </Window>
        </DockPanel>

        <DockPanel x:Name="dockpanel2" HorizontalAlignment="Left" Height="200" LastChildFill="False" Margin="10,209,0,0" VerticalAlignment="Top" Width="772">
            <Window Name="windows2"></Window>
        </DockPanel>
    </Grid>

</Window>

但是不知道如何在代码隐藏中将类实例分配给窗口。我想知道实现的最佳方法,并提供一些示例代码片段。预先感谢。

0 个答案:

没有答案
相关问题