Inserting-Images in WPF RichTextBoxAdv (Classic)

4 May 20212 minutes to read

In order to insert an image in the document, ParagraphAdv provides an inline called ImageContainerAdv.

Properties

Property Description Type Data Type
Height Specifies the height of the image. Dependency Property Double
Width Specifies the width of the image. Dependency Property Double
ImageSource Source of the image. It can be bytes or URL. Dependency Property ImageSource.
ImageBytes Image source can be represented as byte array. Dependency Property Byte[]
FitToContent Fits the image inside the layout when it exceeds the size limit. Dependency Property Boolean

 Adding Images to an Application

ImageContainerAdv can be used to add an image directly to an application using the following code snippet:

<syncfusion:RichTextBoxAdv Height="300" Width="400" x:Name="richtext">            
<syncfusion:DocumentAdv>                
<syncfusion:SectionAdv>                    
<syncfusion:ParagraphAdv >                        
<syncfusion:ImageContainerAdv ImageSource="/RibbonAndRichTextBox;component/OfficeUI/calender.png" Width="100" Height="100"/>                    
</syncfusion:ParagraphAdv>               
 </syncfusion:SectionAdv>            
 </syncfusion:DocumentAdv>        
 </syncfusion:RichTextBoxAdv>
          
RichTextBoxAdv richtext = new RichTextBoxAdv();         
 DocumentAdv document = new DocumentAdv();        
 SectionAdv section = new SectionAdv();          
 ParagraphAdv paragraph = new ParagraphAdv();        
 ImageContainerAdv imagecontainer = new ImageContainerAdv();       
 BitmapImage bitmap = new BitmapImage();         
 bitmap.UriSource = new Uri("/RibbonAndRichTextBox;component/OfficeUI/calender.png");         
 imagecontainer.ImageSource = bitmap;         
 paragraph.Inlines.Add(imagecontainer);         
 section.Blocks.Add(paragraph);          
 document.Sections.Add(section);         
 richtext.Document = document;

 Limitations

Inserting an image has the following limitations:

  1. It does not have a separate context menu.
  2. It does not deal with brightness, reflection, or glow effects of the image.