Search code examples
wpfwinformsvisual-studio-2022.net-7.0

How to add WPF UserControl onto a Form next to already existing form controls in a form designer?


I am interested in reusing old forms with form controls on it, not just any solution to add WPF control to a form. Why? Because this solution spares me from redesigning hundred forms that also have a WPF control on them.

Exception: Microsoft.DotNet.DesignTools.Client.DesignToolsServerException: Component of type UserControl1 could not be created. Make sure the type implements IComponent and provides an appropriate public constructor. Appropriate constructors either take no parameters or take a single IContainer parameter.

To reproduce the problem: https://github.com/hovek/WpfApp1 and try adding UserControl1 to Form1, from the Toolbox.

VS Version 17.4.2


Solution

  • I guess it's not possible to design on a form: https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.integration.elementhost?view=windowsdesktop-7.0