I am trying to host a custom Windows Forms control in WPF. My custom control does not have a public constructor, and it has a static Create()
method which looks something like this:
public abstract class MyCustomControl : UserControl
{
internal MyCustomControl(...) { }
public static MyCustomControl Create(SomeEnum kind)
{
switch (kind)
{
case SomeEnum.Kind1:
return new MySuperCustomControl(...);
...
}
What I want to do is instantiate this custom control in WPF and then have it hosted in WindowsFormsHost
, but I obviously can't add an abstract class:
<wfi:WindowsFormsHost Width="250" Height="150">
<my:MyCustomControl x:Name="customControl" /> <-- doesn't work
</wfi:WindowsFormsHost>
Is there a way I could add it into the "Host" via code?