2

I've got a simple InlineUIContainer inside a Paragraph, inside a RichTextBlock. How can I make the content inside the InlineUIContainer take the full width of the RichTextBlock? Setting the HorizontalAlignment property obviously does nothing, so what can? For the moment I'm using the extremely hacky way of having:

<RichTextBlock>
    <Paragraph>
         <InlineUIContainer>
             <TextBlock Text="__________________________________________________________________" FontSize="72"/>
             <!--Content-->
         </InlineUIContainer>
    </Paragraph>
</RichTextBlock>

This is obviously an extremely bad way of getting it to stretch, so what would work?

user2950509
  • 1,018
  • 2
  • 14
  • 37

1 Answers1

0

InlineUIContainer can't stretch to take whole width of the RichTextBlock. Ref Remarks of InlineUIContainer:

Setting properties on InlineUIContainer that otherwise affect the character line height of a text element (such as FontSize, FontFamily ) has no effect on the rendering and appearance. The content dictates its size and the InlineUIContainer sizes to fit it.

So the width of InlineUIContainer is controlled by its content not its parents. If you want InlineUIContainer to take 100% of the RichTextBlock's width, I'm afraid you have to use some "hacky" way to provide a wide enough content for InlineUIContainer.

Jay Zuo
  • 15,653
  • 2
  • 25
  • 49