WindowsFormsHost.Child Eigenschap

Definitie

Hiermee wordt het onderliggende besturingselement opgehaald of ingesteld dat wordt gehost door het WindowsFormsHost element.

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

Waarde van eigenschap

Het gehoste Windows Forms besturingselement.

Uitzonderingen

Er is geprobeerd een formulier op het hoogste niveau toe te wijzen als het gehoste besturingselement.

Voorbeelden

In het volgende codevoorbeeld ziet u hoe u de Child eigenschap gebruikt om het gehoste besturingselement toe te voegen aan het WindowsFormsHost element. Zie Walkthrough: Een ActiveX-besturingselement hosten in WPF voor meer informatie.

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

Opmerkingen

Slechts één onderliggend besturingselement kan worden gehost, maar Child kan een willekeurig aantal kinderen hebben.

Het onderliggende besturingselement kan geen formulier op het hoogste niveau zijn.

Als Child dit een Formis, wordt de eigenschap van ControlBox het formulier ingesteld op false.

XAML-tekstgebruik

< Object>

< hostedControl.../>

</ Object>

XAML-waarden

Object Een WindowsFormsHost element (of een mogelijke subklasse).

hostedControl Een element waarmee het gehoste Windows Forms besturingselement wordt opgegeven. Voor het opgeven van het aangepaste besturingselement in markeringen is meestal een XMLNS-toewijzing vereist. Zie XAML-naamruimten en naamruimtetoewijzing voor WPF XAML.

Van toepassing op

Zie ook