-
Notifications
You must be signed in to change notification settings - Fork 961
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ElementHost control (Wpf Interoperability) do not display in Toolbox WinForms designer And Can not add Wpf UserControl in winform designer #9443
Comments
@Olina-Zhang can you check if this repros in .net 6 please? |
In my computer, .NET 6 has the same error |
Much appreciated. Team will need to have a look. |
There are known issues in Winforms designer repo: https://github.com/microsoft/winforms-designer/issues/919, https://github.com/microsoft/winforms-designer/issues/2626. |
Sorry, these URLs do not exist. maybe i have not permission |
@MauNguyenVan the designer repo is currently closed source. |
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. |
I spent quite a time on this too, only to finally find this issue. Would love to see this fix as I have customers relying on this control to bring WPF controls into winforms. |
This has been holding me back from migrating my main framework project to .net. On this screen shot you can see I've manually added the wpf ctrl by hand, but if I drag from the toolbox I get this error. |
Is there any news for this problem? I have a project in .net core, but I didn't know about the problem otherwise I would have created the project in .net framework. |
Same here, stuck trying to port to .NET 8. Initially build worked and my ElementHost-ed WPF component worked well and then... it just dissapeared from the designer. I can still see my WPF user control in the Toolbox palette but I can't see Element Host / WPF integration anymore and I can't add the WPF user control directly. It comes up with a generic message how the component should implement IComponent and have suitable constructor but this is already the case and I can use the WPF component in WPF projects so it must be the designer issue. If there is no timeline for the Designer fix, could you at least provide a workaround or any insight into what is happening?? |
@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 |
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 |
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
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. |
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: code to use the control:
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 |
reponing doesn't fix the issue for me, net 8. |
Ok I switched from |
@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 😉 |
@dotMorten , I think having to edit a file that clearly says it shouldn't be edited doesn't suggest its supported. |
Environment
VisualStudio 17.6.4
.NET version
Did this work in a previous version of Visual Studio and/or previous .NET release?
It works in .NET framework 4.8
Issue description
Steps to reproduce
Windows Form App
project with a target framework 7.0.ElementHost
(not found this control)Image WinFormApp .net core 7.0
But with .net framework 4.8 has it and works fine
![Untitled](./?url=aHR0cHM6Ly9wcml2YXRlLXVzZXItaW1hZ2VzLmdpdGh1YnVzZXJjb250ZW50LmNvbS80ODU0NDM1NC8yNTE4ODg1NDItMTI0N2U2YTgtMDM0NS00YzQwLWE4ZWMtMmIzMWQ4M2ZiOGQ3LnBuZz9qd3Q9ZXlKaGJHY2lPaUpJVXpJMU5pSXNJblI1Y0NJNklrcFhWQ0o5LmV5SnBjM01pT2lKbmFYUm9kV0l1WTI5dElpd2lZWFZrSWpvaWNtRjNMbWRwZEdoMVluVnpaWEpqYjI1MFpXNTBMbU52YlNJc0ltdGxlU0k2SW10bGVUVWlMQ0psZUhBaU9qRTNNak01T1RBeU5UUXNJbTVpWmlJNk1UY3lNems0T1RrMU5Dd2ljR0YwYUNJNklpODBPRFUwTkRNMU5DOHlOVEU0T0RnMU5ESXRNVEkwTjJVMllUZ3RNRE0wTlMwMFl6UXdMV0U0WldNdE1tSXpNV1E0TTJaaU9HUTNMbkJ1Wno5WUxVRnRlaTFCYkdkdmNtbDBhRzA5UVZkVE5DMUlUVUZETFZOSVFUSTFOaVpZTFVGdGVpMURjbVZrWlc1MGFXRnNQVUZMU1VGV1EwOUVXVXhUUVRVelVGRkxORnBCSlRKR01qQXlOREE0TVRnbE1rWjFjeTFsWVhOMExURWxNa1p6TXlVeVJtRjNjelJmY21WeGRXVnpkQ1pZTFVGdGVpMUVZWFJsUFRJd01qUXdPREU0VkRFME1EVTFORm9tV0MxQmJYb3RSWGh3YVhKbGN6MHpNREFtV0MxQmJYb3RVMmxuYm1GMGRYSmxQVFJtTmpoa00ySTNNVGRrWldaak1HVXhZekkxTldZME16STVOV016Wm1ZNU16TXpaR1l5T1dOa05ERXhZbVkwTkRobU5Ea3hNbU13TnpGbVlqVXpNalFtV0MxQmJYb3RVMmxuYm1Wa1NHVmhaR1Z5Y3oxb2IzTjBKbUZqZEc5eVgybGtQVEFtYTJWNVgybGtQVEFtY21Wd2IxOXBaRDB3SW4wLlNOS0hid1p1a1pQb0ZSNmI2ZEduSWFqUU5nenNIeGxmU2xwZXcyZWREbGs=&__proxy_form=0)
Diagnostics
No response
The text was updated successfully, but these errors were encountered: