我以前使用过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");
}
}
发布您的代码和XAML。 – 2013-03-18 19:55:41
另外,你想要什么?它看起来像一个可怕的黑客。 – 2013-03-18 19:57:30