ElementHost Class
Assembly: WindowsFormsIntegration (in windowsformsintegration.dll)
XML Namespace: http://schemas.microsoft.com/winfx/2006/xaml/presentation
Use the ElementHost control to place a WPF UIElement on your Windows Forms control or form.
To host a Windows Forms control in a WPF element, use the WindowsFormsHost element.
Note: |
|---|
| WindowsFormsIntegration.dll is installed with the WPF assemblies. The default location for the assembly is %programfiles%\Reference Assemblies\Microsoft\Framework\v3.0\WindowsFormsIntegration.dll. |
To host a WPF element in a Windows Form, you must assign the WPF element to the Child property.
Use the PropertyMap property to assign custom mappings between an ElementHost control and its hosted WPF element. For more information, see Property Mapping.
The following code example demonstrates how to use the ElementHost control to host a WPF element. For more information, see Walkthrough: Hosting a Windows Presentation Foundation UserControl In Windows Forms.
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); }
System.MarshalByRefObject
System.ComponentModel.Component
System.Windows.Forms.Control
System.Windows.Forms.Integration.ElementHost
Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.Reference
ElementHost MembersSystem.Windows.Forms.Integration Namespace
WindowsFormsHost
UIElement
Other Resources
Walkthrough: Hosting a Windows Presentation Foundation Control on a Windows FormSupported Scenarios in Windows Presentation Foundation and Windows Forms Interoperation
Migration and Interoperability
Note: