如何在 .NET 6 中添加 wpf 组件以赢得应用程序
How to add wpf component to win app in .NET 6
我用 .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);
}
我用 .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);
}