Set size of InlineUIContainer?

355 Views Asked by At

I wrapped a TextBlock in an InlineUIContainer inside a RichTextBox, its content is bound to an external multi-line TextBox that the user updates on the spot.

What happens is the InlineUIContainer's size doesn't expand or shrink as needed, it's a static size, I need it to be extended according to the size of the inner TextBlock (I've tested the size of the TextBlock and it does resize according to its content).

Any way to do this? Of course a XAMLy way is preferred, even more verbose.

2

There are 2 best solutions below

0
Shimmy Weitzhandler On BEST ANSWER

I did an ugly and hacky workaround, hope to be able to replace it soon.

I made another property in the ViewModel, that returns:

string.IsNullOrWhitespace(comments) ? 
  string.Empty : 
  string.Format("Comments:{1}{0}{1}", comments, Environment.NewLine);  

It works but is nasty.

3
Markus Hütter On

I don't know if it's a Silverlight thing, but trying out this in Kaxaml works (typing in the Textbox expands it):

<RichTextBox IsDocumentEnabled="true">
  <FlowDocument>
    <Paragraph>
      <Run>cool </Run>
      <InlineUIContainer><TextBox>woohoo</TextBox></InlineUIContainer>
      <Run>stuff</Run>
    </Paragraph>
  </FlowDocument>
</RichTextBox>