This walkthrough demonstrates how you can create a WPF composite control and host it in Windows Forms controls and forms by using the ElementHost control.
In this walkthrough, you will implement a WPF UserControl that contains two child controls. The UserControl displays a three-dimensional (3-D) cone. Rendering 3-D objects is much easier with the WPF than with Windows Forms. Therefore, it makes sense to host a WPF UserControl class to create 3-D graphics in Windows Forms.
Tasks illustrated in this walkthrough include:
For a complete code listing of the tasks illustrated in this walkthrough, see Hosting a Windows Presentation Foundation Composite Control in Windows Forms Sample.
Note The dialog boxes and menu commands you see might differ from those described in Help, depending on your active settings or edition. To change your settings, choose Import and Export Settings on the Tools menu. For more information, see Visual Studio Settings.

Prerequisites
You need the following components to complete this walkthrough:

Creating the UserControl
To create the UserControl

Creating the Windows Forms Host Project
To create the host project
Add a Windows application project named WpfUserControlHost to the solution. For more information, see Add New Project Dialog Box.
In Solution Explorer, add a reference to the WindowsFormsIntegration assembly, which is named WindowsFormsIntegration.dll.
Add references to the following WPF assemblies:
PresentationCore
PresentationFramework
WindowsBase
Add a reference to the HostingWpfUserControlInWf project.
In Solution Explorer, set the WpfUserControlHost project to be the startup project.

Hosting the Windows Presentation Foundation UserControl
To host the UserControl
In the Windows Forms Designer, open Form1.
In the Properties window, click Events, and then double-click the Load event to create an event handler.
The Code Editor opens to the newly generated Form1_Load event handler.
Replace the code in Form1.cs with the following code.
The Form1_Load event handler creates an instance of UserControl1 and adds itto the ElementHost control's collection of child controls. The ElementHost control is added to the form's collection of child controls.
Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Text
Imports System.Windows.Forms
Imports System.Windows.Forms.Integration
Public Class Form1
Inherits Form
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' Create the ElementHost control for hosting the
' WPF UserControl.
Dim host As New ElementHost()
host.Dock = DockStyle.Fill
' Create the WPF UserControl.
Dim uc As 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.
Me.Controls.Add(host)
End Sub
End Class
Press F5 to build and run the application.

See Also
Tasks
Concepts
Reference
Other Resources