如何将用户控件添加到选项卡控件页面,以及如何使用c#winforms在单击按钮时打开整个选项卡控件?
如何在winforms中将用户控件添加到选项卡控件,以及如何单击一个按钮打开整个选项卡控件面板?编辑问题之前: 使用如何将用户控件添加到选项卡控件页面,以及如何使用c#winforms在单击按钮时打开整个选项卡控件?,c#,.net,winforms,C#,.net,Winforms,如何在winforms中将用户控件添加到选项卡控件,以及如何单击一个按钮打开整个选项卡控件面板?编辑问题之前: 使用System.Windows.Forms.Integration.Elementhost。 请发布您目前尝试的代码。或者,您知道,只需发布面板即可。这是执行类似操作的常用控件。@nyrguds您不能创建面板宿主WPF或使用Xaml代码。@shad0wk是问题中指定的吗?它被标记为winforms,而不是WPF。 // Create the ElementHost control
System.Windows.Forms.Integration.Elementhost
。
请发布您目前尝试的代码。或者,您知道,只需发布面板即可。这是执行类似操作的常用控件。@nyrguds您不能创建
面板宿主WPF或使用Xaml代码。@shad0wk是问题中指定的吗?它被标记为winforms,而不是WPF。
// Create the ElementHost control to host the WPF UserControl.
ElementHost WPFHost = new ElementHost();
WPFHost.Dock = DockStyle.Fill;
// Create the WPF UserControl.
HostingWpfUserControlInWf.UserControl1 uc = new HostingWpfUserControlInWf.UserControl1();
// Add the WPF UserControl to the Host.
WPFHost.Child = uc;
// Add the ElementHost to the form.
this.Controls.Add(WPFHost);