This is a migrated thread and some comments may be shown as answers.

InlineUIElement Alignment Problem in RadRichTextBox

0 Answers 88 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
york
Top achievements
Rank 1
york asked on 10 Jan 2013, 07:12 AM
Hi,

I try to add an InlineUIElement for TextBlock to RadRichTextBox. The code is,
// Set font type and size in TextBlock
string fontName = "Verdana";
int fontSize = 12;
System.Windows.Media.FontFamily fontFamily = new System.Windows.Media.FontFamily(fontName);
TextBlock tagBlock = new TextBlock
{
    Background = new SolidColorBrush(Colors.LightGoldenrodYellow),
    FontFamily = fontFamily,
    FontSize = fontSize,
    Text = tagConent
};
 
// Get the size of TextBlock
tagBlock.Measure(new System.Windows.Size(Double.PositiveInfinity, Double.PositiveInfinity));
System.Windows.Size size = new System.Windows.Size(tagBlock.DesiredSize.Width, tagBlock.DesiredSize.Height);
 
// Create an InlineUIContainer containing the TextBlock
Telerik.Windows.Documents.Model.InlineUIContainer tagContainer = new Telerik.Windows.Documents.Model.InlineUIContainer(tagBlock, size);
 
// Insert the InlineUIContainer into the caret position
radRichTextBox1.InsertInline(tagContainer);

It works basically fine except text in TextBlock align top compared to text outside block (See attached picture). This is very similar to one in http://stackoverflow.com/questions/5225268/wpf-how-to-align-text-in-inlineuicontainer-content-with-outer-text-in-richtextb. But I can not find inlineuicontainer.BaselineAlignment as suggested in the post for Telerik.Windows.Documents.Model.InlineUIContainer. I need help on this.

Thanks,
York

No answers yet. Maybe you can help?

Tags
RichTextBox
Asked by
york
Top achievements
Rank 1
Share this question
or