InlineUIElement Alignment Problem in RadRichTextBox

1 posts, 0 answers
  1. york
    york avatar
    160 posts
    Member since:
    Jul 2012

    Posted 10 Jan 2013 Link to this post


    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

    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 But I can not find inlineuicontainer.BaselineAlignment as suggested in the post for Telerik.Windows.Documents.Model.InlineUIContainer. I need help on this.

Back to Top