ElementHost.Child Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets or sets the UIElement hosted by the ElementHost control.
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
Property Value
The hosted Windows Presentation Foundation (WPF) element.
- Attributes
Examples
The following code example demonstrates how to use the Child property to assign a hosted WPF element. For more information, see Walkthrough: Hosting a 3-D WPF Composite Control in Windows Forms.
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
Remarks
Only one element can be hosted, but Child can have any number of child elements.
Applies to
See also
GitHub पर हमारे साथ सहयोग करें
इस सामग्री का स्रोत GitHub पर पाया जा सकता है, जहाँ आप समस्याएँ बना और समीक्षा भी कर सकते हैं और अनुरोध खींच सकते हैं. अधिक जानकारी के लिए, हमारे योगदानकर्ता गाइड देखें.