Skip to main content
A newer version of this page is available. .

How to: Add Floating Picture

To add a floating picture to the document, use the ShapeCollection.InsertPicture method.

Note

A complete sample project is available at https://github.com/DevExpress-Examples/wpf-richedit-document-api-t213968.

document.AppendText("Line One\nLine Two\nLine Three");
StreamResourceInfo streamResInfo = Application.GetResourceStream(new Uri("beverages.png", UriKind.Relative));
if (streamResInfo != null)
{
    using (Stream s = streamResInfo.Stream) 
    {
        Shape myPicture = document.Shapes.InsertPicture(document.CreatePosition(15), 
            DocumentImageSource.FromStream(s));
        myPicture.HorizontalAlignment = ShapeHorizontalAlignment.Center;
    }
}