WindowsFormsHost.Child Proprietà

Definizione

Ottiene o imposta il controllo figlio ospitato dall'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

Valore della proprietà

Control

Controllo Windows Forms ospitato.

Eccezioni

È stato fatto un altro tentativo per assegnare un modulo di livello superiore come controllo di hosting.

Esempio

Nell'esempio di codice seguente viene illustrato come usare la Child proprietà per aggiungere il controllo ospitato all'elemento WindowsFormsHost . Per altre informazioni, vedere Procedura dettagliata: hosting di un controllo ActiveX in 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

Commenti

È possibile ospitare solo un controllo figlio, ma Child può avere un numero qualsiasi di elementi figlio.

Il controllo figlio non può essere un modulo di primo livello.

Se Child è un Formoggetto , la proprietà del ControlBox modulo è impostata su false.

Utilizzo del testo XAML

<Oggetto >

<hostedControl .../>

</Oggetto >

Valori XAML

Oggetto Elemento WindowsFormsHost (o una sottoclasse possibile).

hostedControl Elemento che specifica il controllo Windows Forms ospitato. La specifica del controllo personalizzato nel markup richiede in genere un mapping xmlns, vedere Spazi dei nomi XAML e Mapping dello spazio dei nomi per XAML WPF.

Si applica a

Vedi anche