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 テキストの使用法
<
オブジェクト>
<
hostedControl.../>
</
オブジェクト>
XAML 値
オブジェクトWindowsFormsHost要素 (または可能なサブクラス)。
hostedControl ホストされている Windows フォーム コントロールを指定する要素。 マークアップでカスタム コントロールを指定するには、通常、xmlns マッピングが必要です。 WPF XAML の XAML 名前空間と名前空間マッピングに関するページを参照してください。