We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to host WPF control in Windows Forms project?

Platform: WinForms |
Control: General

Host WPF control in Windows Forms project

It is possible to use Syncfusion WPF controls in Windows Forms Application by following below steps.

Step 1: Create Windows Forms and Windows Forms Control Library Application.


Show the Windows Forms application

Figure 1: Windows Forms Application

Need to create the Windows Control Library application as like in below.


Show the Windows Forms control library application

Figure 2: Windows Forms Control Library Application

Step 2: Configure the required WPF assemblies

Need to add UserControl.Xaml file in Windows Forms Control Library Application and required Syncfusion WPF dependency assemblies.

For example,

Here we are using the Syncfusion SfAccordion WPF control. So, it is needed to add UserControl.xaml file into the project.


Add Xaml file into new application

Figure 3: Adding UserControl.Xaml file into the WindowsControlLibrary application.

Then it is needed to add the necessary configuration for SfAccordion WPF control in the loaded UserControl.Xaml file. The following code snippets explain the same.


<UserControl x:Class="WindowsFormsControlLibrary1.SyncAccordion"
             d:DesignHeight="152" d:DesignWidth="629">
        <syncfusion:SfAccordion x:Name="accordion">
            <syncfusion:SfAccordionItem Header="Windows Phone"/>
            <syncfusion:SfAccordionItem Header="Windows Forms"/>
            <syncfusion:SfAccordionItem Header="Windows Presentation Foundation"/>
            <syncfusion:SfAccordionItem Header="WinRT"/>
            <syncfusion:SfAccordionItem Header="Universal Windows Platform"/>

Step 3: Need to create Element Host class.

To load WPF control in Windows Forms application, it is needed to implement Class derived from ElementHost and load SfAccordion WPF control in it. The following code snippet explains the same.


[Designer("System.Windows.Forms.Design.ControlDesigner, System.Design")]
[DesignerSerializer("System.ComponentModel.Design.Serialization.TypeCodeDomSerializer , System.Design", "System.ComponentModel.Design.Serialization.CodeDomSerializer, System.Design")]
public class SyncAccordionGrid : System.Windows.Forms.Integration.ElementHost
   protected SyncAccordion m_WPFSyncAccordion = new SyncAccordion();
   public SyncAccordionGrid()
      base.Child = m_WPFSyncAccordion;     


<Designer("System.Windows.Forms.Design.ControlDesigner, System.Design"), DesignerSerializer("System.ComponentModel.Design.Serialization.TypeCodeDomSerializer , System.Design", "System.ComponentModel.Design.Serialization.CodeDomSerializer, System.Design")>
Public Class SyncAccordionGrid
    Inherits System.Windows.Forms.Integration.ElementHost
    Protected m_WPFSyncAccordion As New SyncAccordion()
      Public Sub New()
         MyBase.Child = m_WPFSyncAccordion
      End Sub
End Class

Step 4: Need to attach Windows Control Library project into Windows Forms application.

It is needed to attach the created Windows Control Library project into Windows Forms application and add it to its assembly reference section.

Step 5: Need to add SfAccordion control in Windows Forms application.

As both the applications are merged, it is needed to rebuild the whole application. It will add SfAccordion WPF control in Windows Forms Application Designer Page Toolbox. It can be dragged and dropped into the Form Designer.


  Loading WPF Accordion control into WF application

 Figure 4: Loading WPF SfAccordion control into Windows Forms application.

And now it can be used in Windows Forms application.


Accordion control can be used in WF application

   Figure 5:  SfAccordion control can be used in Windows Forms Application.


To run the Application and open the Form Designer, it is needed to rebuild this application.


2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile