You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ElementHost control (Wpf Interoperability) do not display in Toolbox WinForms designer And Can not add Wpf UserControl in winform designer #9443
area-VSDesignerWindows Forms out-of-proc designer related issuesblocking-migrationAn issue that is preventing the developer from migrating from .NET Framework or earlier .NET
changed the title [-]ElementHost (Wpf Interoperability) do not display in Toolbox WinForms designer[/-][+]ElementHost control (Wpf Interoperability) do not display in Toolbox WinForms designer[/+]on Jul 8, 2023
changed the title [-]ElementHost control (Wpf Interoperability) do not display in Toolbox WinForms designer[/-][+]ElementHost control (Wpf Interoperability) do not display in Toolbox WinForms designer And Wpf UserControl can not add in winform designer [/+]on Jul 8, 2023
changed the title [-]ElementHost control (Wpf Interoperability) do not display in Toolbox WinForms designer And Wpf UserControl can not add in winform designer [/-][+]ElementHost control (Wpf Interoperability) do not display in Toolbox WinForms designer And Can not add Wpf UserControl in winform designer [/+]on Jul 8, 2023
@molt2020 the elementhost works just fine - you just have to add it in code (or copy it over from a framework version). It’s only that it won’t show in the designer but otherwise the designer continues to work for other controls
@molt2020 the elementhost works just fine - you just have to add it in code (or copy it over from a framework version). It’s only that it won’t show in the designer but otherwise the designer continues to work for other controls
I didn't succeed without having it in the toolbox. Can you give some examples of how you managed to integrate the control. A thousand thanks.
@bernox89 I just reverted code back to what Designer made and after Designer decided to remove the entire component from the designer code. So far, the Designer has not removed the code again. Here is the code in case it is helpful
private System.Windows.Forms.Integration.ElementHost elementHost_CurrentRecordInfo; this.elementHost_CurrentRecordInfo = new System.Windows.Forms.Integration.ElementHost(); this.elementHost_CurrentRecordInfo.Child = this.myWPFControl;
there is no other ElementHost-specific code to hoist the myWPFControl into it. There is some extra code int the designer to place the elementHost_CurrentRecordInfo onto the Windows Form (i.e. into a Grid Cell etc) which will be different for your project anyway so I have removed it from the post here as clutter.
You don't have to keep this in the .Designer.cs file either if you worry the Designer may overwrite or remove it.
thanks for the help anyway. I solved it independently only from C# code following these steps, without having elementhost available from the toolbox:
Set properties in winforms project to also use WPF
Import any WPF libraries using project references
Enter any uses for the wpf controls/libraries
with this code example it works great, in my case I needed to have the syncfusion tool to edit images and have it on winforms which does not exist natively.
using section: using System.Windows.Forms.Integration; using Syncfusion.Licensing; using Syncfusion.Windows.Controls; using Syncfusion.Windows.Shared; using Syncfusion.Windows.Tools; using Syncfusion.UI.Xaml.ImageEditor;
code to use the control:
SfImageEditor imageEditor = new SfImageEditor(); ElementHost host = new ElementHost(); host.Dock = DockStyle.Fill; host.Child = imageEditor; this.Controls.Add(host); host.Dock = DockStyle.Fill;
I hope I have been useful to someone
the only thing we don't have is the graphic control available in the designer, but it comes second in my opinion.
While its possible to add a wpf control/ElementHost by hand I'm reluctant to do this in my production project as it doesn't feel like its supported by Microsoft. Perhaps this is Microsoft's way of pushing us to use WinUI 3? I wouldn't mind but WinUI is missing so many features, feels like its still very early in development. So for now I'm choosing to stay with .net framework which I don't really want to.
Started to get this behaviour after updating vs to 17.10. Stopped using the out of process designer for winforms, reopened the solution and now it's back in the toolbox
@ImHappyMostOfTheTime what makes you think it isn’t supported? It’s fully supported in your app. It is only the design time experience that isn’t. If a lacking design time experience would be the reason something isn’t supported you’d think winui3 is completely unsupported since it doesn’t have a designer at all 😉
This is still an issue over two years later. This is BLOCKING people from using WPF controls in WinForms. Yes, you can manually edit the designer.cs file, but if you utilize the designer application for ANYTHING, these added lines will randomly be removed and you will have to manually readd them.
area-VSDesignerWindows Forms out-of-proc designer related issuesblocking-migrationAn issue that is preventing the developer from migrating from .NET Framework or earlier .NET
Activity
[-]ElementHost (Wpf Interoperability) do not display in Toolbox WinForms designer[/-][+]ElementHost control (Wpf Interoperability) do not display in Toolbox WinForms designer[/+][-]ElementHost control (Wpf Interoperability) do not display in Toolbox WinForms designer[/-][+]ElementHost control (Wpf Interoperability) do not display in Toolbox WinForms designer And Wpf UserControl can not add in winform designer [/+][-]ElementHost control (Wpf Interoperability) do not display in Toolbox WinForms designer And Wpf UserControl can not add in winform designer [/-][+]ElementHost control (Wpf Interoperability) do not display in Toolbox WinForms designer And Can not add Wpf UserControl in winform designer [/+]elachlan commentedon Jul 8, 2023
@Olina-Zhang can you check if this repros in .net 6 please?
MauNguyenVan commentedon Jul 8, 2023
In my computer, .NET 6 has the same error
elachlan commentedon Jul 8, 2023
Much appreciated. Team will need to have a look.
Olina-Zhang commentedon Jul 10, 2023
There are known issues in Winforms designer repo: https://github.com/microsoft/winforms-designer/issues/919, https://github.com/microsoft/winforms-designer/issues/2626.
MauNguyenVan commentedon Jul 10, 2023
Sorry, these URLs do not exist. maybe i have not permission
elachlan commentedon Jul 10, 2023
@MauNguyenVan the designer repo is currently closed source.
merriemcgaw commentedon Jul 12, 2023
This is known work that we have on our backlog in our private Designer repo. We don't have a specific timeline yet. We will keep you posted.
4 remaining items
dotMorten commentedon May 4, 2024
@molt2020 the elementhost works just fine - you just have to add it in code (or copy it over from a framework version). It’s only that it won’t show in the designer but otherwise the designer continues to work for other controls
molt2020 commentedon May 4, 2024
Thank you @dotMorten - I reverted the code and it compiles and works! 👍
It would be good to have this fixed so it shows in the palette as manually editing designer files is no fun
bernox89 commentedon May 4, 2024
I didn't succeed without having it in the toolbox. Can you give some examples of how you managed to integrate the control. A thousand thanks.
molt2020 commentedon May 5, 2024
@bernox89 I just reverted code back to what Designer made and after Designer decided to remove the entire component from the designer code. So far, the Designer has not removed the code again. Here is the code in case it is helpful
private System.Windows.Forms.Integration.ElementHost elementHost_CurrentRecordInfo; this.elementHost_CurrentRecordInfo = new System.Windows.Forms.Integration.ElementHost(); this.elementHost_CurrentRecordInfo.Child = this.myWPFControl;there is no other ElementHost-specific code to hoist the myWPFControl into it. There is some extra code int the designer to place the elementHost_CurrentRecordInfo onto the Windows Form (i.e. into a Grid Cell etc) which will be different for your project anyway so I have removed it from the post here as clutter.
You don't have to keep this in the .Designer.cs file either if you worry the Designer may overwrite or remove it.
Hope it helps.
bernox89 commentedon May 19, 2024
thanks for the help anyway. I solved it independently only from C# code following these steps, without having elementhost available from the toolbox:
using section:
using System.Windows.Forms.Integration; using Syncfusion.Licensing; using Syncfusion.Windows.Controls; using Syncfusion.Windows.Shared; using Syncfusion.Windows.Tools; using Syncfusion.UI.Xaml.ImageEditor;code to use the control:
SfImageEditor imageEditor = new SfImageEditor(); ElementHost host = new ElementHost(); host.Dock = DockStyle.Fill; host.Child = imageEditor; this.Controls.Add(host); host.Dock = DockStyle.Fill;I hope I have been useful to someone
the only thing we don't have is the graphic control available in the designer, but it comes second in my opinion.
ImHappyMostOfTheTime commentedon May 21, 2024
While its possible to add a wpf control/ElementHost by hand I'm reluctant to do this in my production project as it doesn't feel like its supported by Microsoft. Perhaps this is Microsoft's way of pushing us to use WinUI 3? I wouldn't mind but WinUI is missing so many features, feels like its still very early in development. So for now I'm choosing to stay with .net framework which I don't really want to.
IefVandepitte commentedon Jun 25, 2024
Started to get this behaviour after updating vs to 17.10. Stopped using the out of process designer for winforms, reopened the solution and now it's back in the toolbox
xmaxrayx commentedon Jul 13, 2024
reponing doesn't fix the issue for me, net 8.
xmaxrayx commentedon Jul 13, 2024
Ok I switched from
Net 8toNET Framework 4(only windows), and fixed my issue.dotMorten commentedon Jul 13, 2024
@ImHappyMostOfTheTime what makes you think it isn’t supported? It’s fully supported in your app. It is only the design time experience that isn’t. If a lacking design time experience would be the reason something isn’t supported you’d think winui3 is completely unsupported since it doesn’t have a designer at all 😉
ImHappyMostOfTheTime commentedon Jul 15, 2024
@dotMorten , I think having to edit a file that clearly says it shouldn't be edited doesn't suggest its supported.
ImHappyMostOfTheTime commentedon Nov 13, 2024
Still broken in .net 9
SuschNL commentedon Aug 25, 2025
This is still an issue over two years later. This is BLOCKING people from using WPF controls in WinForms. Yes, you can manually edit the designer.cs file, but if you utilize the designer application for ANYTHING, these added lines will randomly be removed and you will have to manually readd them.
nRoger-Env commentedon May 13, 2026
Still invisible in .net10