WindowsFormsHost.Child Propiedad

Definición

Obtiene o establece el control secundario hospedado por el elemento WindowsFormsHost.

public:
 property System::Windows::Forms::Control ^ Child { System::Windows::Forms::Control ^ get(); void set(System::Windows::Forms::Control ^ value); };
public System.Windows.Forms.Control Child { get; set; }
member this.Child : System.Windows.Forms.Control with get, set
Public Property Child As Control

Valor de propiedad

Control

Control de Windows Forms hospedado.

Excepciones

Se intentó asignar un formulario de nivel superior como control hospedado.

Ejemplos

En el ejemplo de código siguiente se muestra cómo usar la Child propiedad para agregar el control hospedado al WindowsFormsHost elemento . Para obtener más información, vea Tutorial: Hospedaje de un control de ActiveX en WPF.

private void Window_Loaded(object sender, RoutedEventArgs e) 
{
    // Create the interop host control.
    System.Windows.Forms.Integration.WindowsFormsHost host =
        new System.Windows.Forms.Integration.WindowsFormsHost();

    // Create the ActiveX control.
    var axWmp = new WmpAxLib.AxWindowsMediaPlayer();

    // Assign the ActiveX control as the host control's child.
    host.Child = axWmp;

    // Add the interop host control to the Grid
    // control's collection of child controls.
    this.grid1.Children.Add(host);

    // Play a .wav file with the ActiveX control.
    axWmp.URL = @"C:\Windows\Media\tada.wav";
}
Private Sub Window_Loaded(ByVal sender As Object, ByVal e As RoutedEventArgs)

    ' Create the interop host control.
    Dim host As New System.Windows.Forms.Integration.WindowsFormsHost()

    ' Create the ActiveX control.
    Dim axWmp As New AxWMPLib.AxWindowsMediaPlayer()

    ' Assign the ActiveX control as the host control's child.
    host.Child = axWmp

    ' Add the interop host control to the Grid
    ' control's collection of child controls.
    Me.grid1.Children.Add(host)

    ' Play a .wav file with the ActiveX control.
    axWmp.URL = "C:\Windows\Media\tada.wav"

End Sub

Comentarios

Solo se puede hospedar un control secundario, pero Child puede tener cualquier número de elementos secundarios.

El control secundario no puede ser un formulario de nivel superior.

Si Child es , Formla propiedad del ControlBox formulario se establece en false.

Uso de texto XAML

< object >

<hostedControl .../>

</ object >

Valores XAML

Objeto Un WindowsFormsHost elemento (o una posible subclase).

hostedControl Elemento que especifica el control de Windows Forms hospedado. La especificación del control personalizado en el marcado normalmente requiere una asignación de xmlns, consulta Espacios de nombres XAML y Asignación de espacios de nombres para XAML de WPF.

Se aplica a

Consulte también