我使用 .Net 6
创建了一个项目 Win App
。
我想将 wpf
组件添加到我的项目中,但我在 toolbox
中找不到 ElementHost
控件。
此控件是否已删除?
如果是,如何将wpf
控件添加到win
应用程序?
最佳答案
.NET 6 Winform 设计器似乎不支持 ElementHost。
[我的版本是 Visual Studio 2022 17.1.1]
尝试手动添加 ElementHost
private System.Windows.Forms.Integration.ElementHost elementHost;
private void InitElementHost()
{
this.SuspendLayout();
this.elementHost.Location = new System.Drawing.Point(236, 156); //location
this.elementHost.Name = "elementHost1";
this.elementHost.Size = new System.Drawing.Size(200, 100);
this.elementHost.TabIndex = 0;
this.elementHost.Text = "elementHost1";
this.elementHost.Child = null; //wpf control
this.ResumeLayout(false);
}
关于c# - 如何在.NET 6中添加wpf组件到win应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71880529/