Aracılığıyla paylaş


WindowsFormsHost.Child Özellik

Tanım

öğesi tarafından WindowsFormsHost barındırılan alt denetimi alır veya ayarlar.

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

Özellik Değeri

Barındırılan Windows Forms denetimi.

Özel durumlar

Barındırılan denetim olarak üst düzey bir form atanmaya çalışıldı.

Örnekler

Aşağıdaki kod örneği, barındırılan Child denetimi WindowsFormsHost öğesine eklemek için özelliğinin nasıl kullanılacağını gösterir. Daha fazla bilgi için bkz . İzlenecek yol: WPF'de ActiveX Denetimi Barındırma.

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

Açıklamalar

Yalnızca bir alt denetim barındırılabilir, ancak Child herhangi bir sayıda alt öğeye sahip olabilir.

Alt denetim üst düzey bir form olamaz.

ise ChildForm, formun ControlBox özelliği olarak falseayarlanır.

XAML Metin Kullanımı

< nesne>

< hostedControl.../>

</ nesne>

XAML Değerleri

Nesne Bir WindowsFormsHost öğe (veya olası bir alt sınıf).

hostedControl Barındırılan Windows Forms denetimini belirten bir öğe. İşaretlemede özel denetimi belirtmek için genellikle xmln eşlemesi gerekir. Bkz. WPF XAML için XAML Ad Alanları ve Ad Alanı Eşlemesi.

Şunlara uygulanır

Ayrıca bkz.