来自MSDN:
使用ElementHost控件在Windows窗体控件或窗体上放置WPF UIElement.
例:
private void Form1_Load(object sender, EventArgs e)
{
// Create the ElementHost control for hosting the
// WPF UserControl.
ElementHost host = new ElementHost();
host.Dock = DockStyle.Fill;
// Create the WPF UserControl.
HostingWpfUserControlInWf.UserControl1 uc =
new HostingWpfUserControlInWf.UserControl1();
// Assign the WPF UserControl to the ElementHost control's
// Child property.
host.Child = uc;
// Add the ElementHost control to the form's
// collection of child controls.
this.Controls.Add(host);
}
Run Code Online (Sandbox Code Playgroud)
这是一个很好的教程如何做到这一点.
名为ElementHost的控件用于WinForms中的WPF,WindowsFormsHost是WPF中WinForms的用途.在设计器中,您可以在"WPF互操作性"下的工具箱中找到此控件.
| 归档时间: |
|
| 查看次数: |
4887 次 |
| 最近记录: |