[Expand]General Information
[Expand]WinForms Controls
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Collapse]WPF Controls
  Prerequisites
 [Expand]What's Installed
 [Expand]Common Concepts
 [Expand]MVVM Framework
 [Collapse]Controls and Libraries
   Reporting
  [Expand]Data Grid
  [Expand]Ribbon, Bars and Menu
  [Expand]Charts Suite
  [Expand]Pivot Grid
  [Expand]Scheduler
  [Expand]Spreadsheet
  [Collapse]Rich Text Editor
   [Expand]Product Information
    Product Class Structure
    Supported Formats
   [Expand]Getting Started
   [Collapse]RichEditControl Document
    [Expand]Document Structure
    [Collapse]Document Elements
      Positions and Ranges
      Characters
      Paragraphs
      Inline Pictures
      Hyperlinks and Bookmarks
      Headers and Footers
      Tables
      Range Permissions
      Sections
      Styles
      Lists
      Shapes
      Text Boxes
      Comments
      Checkboxes
      Document Properties
   [Expand]Fields
    Text Formatting
    Import and Export
   [Expand]Page Layout
    Printing
    AutoCorrect
    Mail Merge
    Restrictions and Protection
    Syntax Highlighting
   [Expand]Visual Elements
    Services
    Events
    Commands
    HTML Tag Support
   [Expand]Examples
  [Expand]Tree List
  [Expand]Gauge Controls
  [Expand]Map Control
  [Expand]Layout Management
  [Expand]Windows Modern UI
  [Expand]Printing-Exporting
  [Expand]Data Editors
  [Expand]Navigation Controls
  [Expand]Spell Checker
  [Expand]Property Grid
  [Expand]PDF Viewer
  [Expand]TreeMap Control
  [Expand]Gantt Control
  [Expand]Diagram Control
  [Expand]Windows and Utility Controls
   Dialogs, Notifications and Panels
  [Expand]Scheduler (legacy)
 [Expand]Scaffolding Wizard
 [Expand]Localization
  Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Reporting
[Expand]Report and Dashboard Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

Shapes

The WPF Rich Text Editor allows you to view, print and export (PDF) documents containing shapes. The RichEditControl supports all shape types: from simple lines and rectangles to 3-D shapes with advanced effects.

This document covers:

Expanded Shapes in the User Interface

End-users can move, resize, rotate, or remove shapes.

When end–users select the shape, the Picture Tools contextual tab becomes available. Items on this tab allow you to change the shape's position, text flow around the drawing object, and define the shape fill or outline color.

The RichEditControl provides the Shape Layout Dialog. This dialog allows end-users to specify advanced drawing object's properties. You can invoke this dialog from the shape's context menu.

Important

The RichEditControl provides user interface elements to create text boxes and pictures only. You cannot create or edit other shape types.

Expanded Manage Shapes in Code

You can perform the following actions with shapes.

Access a Shape

The ShapeCollection contains all document drawing objects. Access the collection using the SubDocument.Shapes property. You can retrieve the collection item its index or name using the array notation. Use the Shape.Name property to specify the drawing object's name. Assign the Shape.Range to the Document.Selection property to select a shape.

Important

The ShapeCollection collection does not include all shape objects, so you access and modify only text boxes and pictures in code.

Create a Shape

The RichEditControl provides the following API to create only pictures and text boxes.

Tip

Check the shape's Shape.TextBox property to distinguish the text box from the picture.

Modify a Shape

Position

Use the Shape.TextWrapping property to specify the text flow around the drawing object. The following properties define the drawing object's position within the document.

API Description
Shape.ZOrder Places the floating object behind or in front of other shapes contained in the document.
Shape.Offset Positions the object relative to a certain point.
Shape.HorizontalAlignment <br>Shape.VerticalAlignment Positions the object relative to the page elements.
Shape.RelativeHorizontalPosition<br>Shape.RelativeVerticalPosition Defines the page element to which the object position is relative.

The code snippet below uses the [Shape.ZOrder](xref:DevExpress.XtraRichEdit.API.Native.Shape.ZOrder property to position an image behind the specified drawing object and sets the Shape.TextWrapping property to place the image behind the text.

Rotate and Resize

Use the Shape.RotationAngle property to rotate the shape. The Shape.Size property defines the shape's size. Set the Shape.ScaleX or Shape.ScaleY property to scale the shape horizontally or vertically.

The following code rotates text boxes and resizes floating pictures.

Change Fill and Outline Colors

You can specify the shape outline color and thickness. Retrieve the border line using the Shape.Line property and set its ShapeLine.Color and ShapeLine.Thickness properties. If the floating object's background is transparent, you can change the fill color using the ShapeFill.Color property.

The code sample below changes the fill color and specifies the outline thickness and color for the text box.

Delete the Shape

The ShapeCollection items cannot be deleted. Delete the range related to the shape's anchor to remove the drawing object. Retrieve the range using the Shape.Range property and pass it to the SubDocument.Delete method.

Expanded See Also

Is this topic helpful?​​​​​​​