InlineUIContainer.Child Property

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Gets or sets the UIElement hosted by the InlineUIContainer.

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

Syntax

'Declaration
Public Property Child As UIElement
public UIElement Child { get; set; }
<InlineUIContainer ...>
  singleChild
</InlineUIContainer>

XAML Values

  • singleChild
    Exactly one child element that displays within the UI container. This must be a type that derives from UIElement.

Property Value

Type: System.Windows.UIElement
The UIElement hosted by the InlineUIContainer.

Remarks

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.

Examples

The following code example shows how you can insert an image into a RichTextBox by using the Child property.

'Insert an image into the RichTextBox
Private Sub btnImage_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
    Dim container As InlineUIContainer = New InlineUIContainer
    container.Child = MainPage.createImageFromUri(New Uri("/RichNotepad;component/images/Desert.jpg", UriKind.RelativeOrAbsolute), 200, 150)
    rtb.Selection.Insert(container)
    'ReturnFocus()
End Sub

Private Shared Function createImageFromUri(ByVal URI As Uri, ByVal width As Double, ByVal height As Double) As Image
    Dim img As Image = New Image
    img.Stretch = Stretch.Uniform
    img.Width = width
    img.Height = height
    Dim bi As BitmapImage = New BitmapImage(URI)
    img.Source = bi
    img.Tag = bi.UriSource.ToString
    Return img
End Function
//Insert an image into the RichTextBox
private void btnImage_Click(object sender, RoutedEventArgs e)
{
    InlineUIContainer container = new InlineUIContainer();

    container.Child = MainPage.createImageFromUri(new Uri("/RichNotepad;component/images/Desert.jpg", UriKind.RelativeOrAbsolute), 200, 150);

    rtb.Selection.Insert(container);
    ReturnFocus();
}

private static Image createImageFromUri(Uri URI, double width, double height)
{
    Image img = new Image();
    img.Stretch = Stretch.Uniform;
    img.Width = width;
    img.Height = height;
    BitmapImage bi = new BitmapImage(URI);
    img.Source = bi;
    img.Tag = bi.UriSource.ToString();
    return img;
}

Version Information

Silverlight

Supported in: 5, 4

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.