WPF实现MDI窗体

来源:互联网 发布:linux yum网络安装 编辑:程序博客网 时间:2024/05/16 12:30

添加引用API方法

using System.Runtime.InteropServices;using System.Windows.Interop;namespace JfCooperate{    /// <summary>    /// frmMain.xaml 的交互逻辑    /// </summary>    public partial class frmMain : MetroWindow    {        public class Win32Native        {            [DllImport("user32.dll", EntryPoint = "SetParent")]            public extern static IntPtr SetParent(IntPtr childPtr, IntPtr parentPtr);        }       }


创建MDI子窗体时代码


<span style="font-family:KaiTi_GB2312;font-size:24px;">一般用户.frmQueryBalance f1=new 一般用户.frmQueryBalance();            f1.Show();            WindowInteropHelper parentHelper = new WindowInteropHelper(this);            WindowInteropHelper childHelper = new WindowInteropHelper(f1);            Win32Native.SetParent(childHelper.Handle, parentHelper.Handle);</span>


WinForms实现方法

private void button1_Click(object sender, RoutedEventArgs e){    Window子窗体 w2 = new Window子窗体();    w2.MdiParent = this;    w2.Show();



0 0
原创粉丝点击