Windows apps
Collapse the table of content
Expand the table of content
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

InlineUIContainer.Child Property


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Gets or sets the UIElement hosted by the InlineUIContainer.

Namespace:   System.Windows.Documents
Assembly:  PresentationFramework (in PresentationFramework.dll)

public UIElement Child { get; set; }

Property Value

Type: System.Windows.UIElement

The UIElement hosted by the InlineUIContainer.

An InlineUIContainer may directly host no more than one UIElement child. However, the child element hosted by an InlineUIContainer may host children of its own.

In XAML, wrapping a UIElement in an InlineUIContainer is equivalent to setting that UIElement as the value of the Child property.

The following example shows how to use the InlineUIContainer elements to host UIElement elements within flow content.

<FlowDocument ColumnWidth="400">
  <Paragraph Background="GhostWhite">
      A UIElement element may be embedded directly in flow content
      by enclosing it in an InlineUIContainer element.
      <Button>Click me!</Button>
      The InlineUIContainer element may host no more than one top-level
      UIElement.  However, other UIElements may be nested within the
      UIElement contained by an InlineUIContainer element.  For example,
      a StackPanel can be used to host multiple UIElement elements within
      an InlineUIContainer element.
        <Label Foreground="Blue">Choose a value:</Label>
          <ComboBoxItem IsSelected="True">a</ComboBoxItem>
        <Label Foreground ="Red">Choose a value:</Label>
        <Label>Enter a value:</Label>
          A text editor embedded in flow content.

The following figure shows how this example renders.

Screenshot: UIElement elements embedded in flow

The following example shows how to use the Child property programmatically.

Paragraph parx = new Paragraph();
Run run1 = new Run(" Text to precede the button... ");
Run run2 = new Run(" Text to follow the button... ");

// Create a new button to be hosted in the paragraph.
Button buttonx = new Button();
buttonx.Content = "Click me!";

// Create a new InlineUIContainer, and assign the button 
// as the UI container's child.
InlineUIContainer uiCont = new InlineUIContainer();
uiCont.Child = buttonx;

// Add the text runs and UI container to the paragraph, in order.

.NET Framework
Available since 3.0
Available since 4.0
Windows Phone Silverlight
Available since 7.1
Return to top
© 2018 Microsoft