ElementHost.Child Propriété

Définition

Obtient ou définit le UIElement hébergé par le contrôle ElementHost.

public:
 property System::Windows::UIElement ^ Child { System::Windows::UIElement ^ get(); void set(System::Windows::UIElement ^ value); };
[System.ComponentModel.Browsable(false)]
public System.Windows.UIElement Child { get; set; }
[<System.ComponentModel.Browsable(false)>]
member this.Child : System.Windows.UIElement with get, set
Public Property Child As UIElement

Valeur de propriété

Élément Windows Presentation Foundation hébergé (WPF).

Attributs

Exemples

L’exemple de code suivant montre comment utiliser la Child propriété pour affecter un élément WPF hébergé. Pour plus d’informations, consultez Procédure pas à pas : hébergement d’un contrôle composite WPF 3D dans 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);
}
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

Remarques

Un seul élément peut être hébergé, mais Child peut avoir un nombre quelconque d’éléments enfants.

S’applique à

Voir aussi