以前に WindowsFormsIntegration.dll を使用したことがありますが、正常に動作します。これは、開始するのに役立ちます。最初に WindowsFormsIntegration への参照を追加します。それから...
using System.Windows.Forms.Integration;
...
private void Window_Loaded(object sender, RoutedEventArgs e)
{
var form = new Form1();
form.TopLevel = false;
WindowsFormsHost host = new WindowsFormsHost();
host.Child = form;
host.VerticalAlignment = System.Windows.VerticalAlignment.Top;
host.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
grid.Children.Add(host);
}
...
<Window x:Class="WpfSandbox.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525"
Loaded="Window_Loaded">
<Grid x:Name="grid">
</Grid>
</Window>
そして今、単純なwinformのために
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
MessageBox.Show("hello");
}
}