Export (0) Print
Expand All

ElementHost.Child Property

Gets or sets the UIElement hosted by the ElementHost control.

Namespace: System.Windows.Forms.Integration
Assembly: WindowsFormsIntegration (in windowsformsintegration.dll)
XML Namespace:  http://schemas.microsoft.com/winfx/2006/xaml/presentation

public UIElement Child { get; set; }
/** @property */
public UIElement get_Child ()

/** @property */
public void set_Child (UIElement value)

public function get Child () : UIElement

public function set Child (value : UIElement)

Not applicable.

Property Value

The hosted Windows Presentation Foundation (WPF) element.

Only one element can be hosted, but Child can have any number of child elements.

The following code example demonstrates how to use the Child property to assign a hosted 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);
}

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.

.NET Framework

Supported in: 3.0

Community Additions

ADD
Show:
© 2014 Microsoft