Windows 表单 ElementHost 托管一个 wpf 菜单用户控件,它在 windows 表单主机上打开 windows 表单子项
Windows form ElementHost hosting a wpf menu usercontrol that opens windows forms childs on the windows forms host
我知道这可能看起来有点混乱,但我有一个内置 Windows 表单的应用程序,它有一个菜单和树视图中的近 20 个选项,可打开 Windows 表单子项主要形式,但它看起来很糟糕,所以我想在 wpf 中构建一个具有选项和故事板的用户控件,但我的问题是当我单击wpf 用户控件
有人知道这可能吗?
ElementHost host = new ElementHost();
UserControl2 uc1 = new UserControl2();
host.Child = uc1;
host.Dock = DockStyle.Fill;
this.Controls.Add(host);
我是按照这个逻辑做的
public FormParent parent { get; set; }
private void button_Click(object sender, RoutedEventArgs e)
{
var source = (HwndSource)PresentationSource.FromDependencyObject(button);
var host = (System.Windows.Forms.Integration.ElementHost)System.Windows.Forms.Control.FromChildHandle(source.Handle);
var form = (System.Windows.Forms.Form)host.TopLevelControl;
FormChild newMDIChild = new FormChild();
newMDIChild.MdiParent = form;
newMDIChild.Show();
我知道这可能看起来有点混乱,但我有一个内置 Windows 表单的应用程序,它有一个菜单和树视图中的近 20 个选项,可打开 Windows 表单子项主要形式,但它看起来很糟糕,所以我想在 wpf 中构建一个具有选项和故事板的用户控件,但我的问题是当我单击wpf 用户控件
有人知道这可能吗?
ElementHost host = new ElementHost();
UserControl2 uc1 = new UserControl2();
host.Child = uc1;
host.Dock = DockStyle.Fill;
this.Controls.Add(host);
我是按照这个逻辑做的
public FormParent parent { get; set; }
private void button_Click(object sender, RoutedEventArgs e)
{
var source = (HwndSource)PresentationSource.FromDependencyObject(button);
var host = (System.Windows.Forms.Integration.ElementHost)System.Windows.Forms.Control.FromChildHandle(source.Handle);
var form = (System.Windows.Forms.Form)host.TopLevelControl;
FormChild newMDIChild = new FormChild();
newMDIChild.MdiParent = form;
newMDIChild.Show();