WindowsFormsHost.Child プロパティ
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
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
プロパティ値
ホストされているWindows フォーム コントロール。
例外
トップレベルのフォームをホストされるコントロールとして割り当てようとしました。
例
次のコード例は、プロパティを使用 Child して、ホストされたコントロールを要素に追加する方法を WindowsFormsHost 示しています。 詳細については、「チュートリアル: WPF でのActiveX コントロールのホスト」を参照してください。
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
注釈
ホストできる子コントロールは 1 つだけですが Child 、任意の数の子を持つことができます。
子コントロールを最上位のフォームにすることはできません。
場合 Child は Form、フォームの ControlBox プロパティがに false
設定されます。
XAML テキストの使用法
<
object >
<
hostedControl .../>
</
object >
XAML 値
オブジェクトWindowsFormsHost要素 (または可能なサブクラス)。
hostedControl ホストされるWindows フォーム コントロールを指定する要素。 マークアップでカスタム コントロールを指定するには、通常、xmlns マッピングが必要です。 WPF XAML の XAML 名前空間と名前空間マッピングに関するページを参照してください。