ElementHost.Child 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得或設定由 UIElement 控制項所裝載的 ElementHost。
public:
property System::Windows::UIElement ^ Child { System::Windows::UIElement ^ get(); void set(System::Windows::UIElement ^ value); };
[System.ComponentModel.Browsable(false)]
public System.Windows.UIElement Child { get; set; }
[<System.ComponentModel.Browsable(false)>]
member this.Child : System.Windows.UIElement with get, set
Public Property Child As UIElement
屬性值
裝載Windows Presentation Foundation (WPF) 專案。
- 屬性
範例
下列程式碼範例示範如何使用 Child 屬性來指派裝載的 WPF 專案。 如需詳細資訊,請參閱逐步解說:在 Windows Forms 中裝載 3D WPF 複合控制項。
private void Form1_Load(object sender, EventArgs e)
{
// Create the ElementHost control for hosting the
// WPF UserControl.
ElementHost host = new ElementHost();
host.Dock = DockStyle.Fill;
// Create the WPF UserControl.
HostingWpfUserControlInWf.UserControl1 uc =
new HostingWpfUserControlInWf.UserControl1();
// Assign the WPF UserControl to the ElementHost control's
// Child property.
host.Child = uc;
// Add the ElementHost control to the form's
// collection of child controls.
this.Controls.Add(host);
}
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' Create the ElementHost control for hosting the
' WPF UserControl.
Dim host As New ElementHost()
host.Dock = DockStyle.Fill
' Create the WPF UserControl.
Dim uc As New HostingWpfUserControlInWf.UserControl1()
' Assign the WPF UserControl to the ElementHost control's
' Child property.
host.Child = uc
' Add the ElementHost control to the form's
' collection of child controls.
Me.Controls.Add(host)
End Sub
備註
只能裝載一個專案,但 Child 可以有任意數目的子項目。