カスタム Windows フォーム コントロールを WPF でホストしようとしています。私のカスタム コントロールにはパブリック コンストラクターがなく、Create()
次のような静的メソッドがあります。
public abstract class MyCustomControl : UserControl
{
internal MyCustomControl(...) { }
public static MyCustomControl Create(SomeEnum kind)
{
switch (kind)
{
case SomeEnum.Kind1:
return new MySuperCustomControl(...);
...
}
私がやりたいことは、このカスタム コントロールを WPF でインスタンス化し、それを でホストすることですがWindowsFormsHost
、明らかに抽象クラスを追加することはできません。
<wfi:WindowsFormsHost Width="250" Height="150">
<my:MyCustomControl x:Name="customControl" /> <-- doesn't work
</wfi:WindowsFormsHost>
コードを介して「ホスト」に追加する方法はありますか?