How to: Copy and Paste an ElementHost Control at Design Time

.NET Framework (current version)
 

This procedure shows you how to copy a Windows Presentation Foundation (WPF) control on a Windows Form.

System_CAPS_ICON_note.jpg 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 Customizing Development Settings in Visual Studio.

To copy and paste an ElementHost control at design time

  1. Add a new WPF UserControl to your Windows Forms project. Use the default name for the control type, UserControl1.xaml. For more information, see Walkthrough: Creating New WPF Content on Windows Forms at Design Time.

  2. In the Properties window, set the value of the Width and Height properties of UserControl1 to 200.

  3. Set the value of the Background property to Blue.

  4. Build the project.

  5. Open Form1 in the Windows Forms Designer.

  6. From the Toolbox, drag an instance of UserControl1 onto the form.

    An instance of UserControl1 is hosted in a new ElementHost control named elementHost1.

  7. With elementHost1 selected, press CTRL+C to copy it to the clipboard.

  8. Press CTRL+V to paste the copied control onto the form.

    A new ElementHost control named elementHost2 is created on the form.

ElementHost
WindowsFormsHost
Walkthrough: Copying and Pasting an ElementHost Control into Separate Windows Forms
Migration and Interoperability
Using WPF Controls
WPF Designer

Show: