如何将用户控件添加到选项卡控件页面以及如何使用c#winforms打开按钮单击时的整个选项卡控件?

时间:2016-06-29 07:16:12

标签: c# .net winforms

如何将用户控件添加到winforms中的选项卡控件以及如何在单击按钮上打开整个选项卡控件面板?

1 个答案:

答案 0 :(得分:0)

在编辑问题之前:

使用System.Windows.Forms.Integration.ElementhostMSDN

// 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);

Or you can use XAML to design Winform Project GUI