Search code examples
wpfxaml.net-4.0richtextboxexpander

RichTextBox inside Expander in WPF


<Expander Header="More options" Margin="281,218,39,12">
    <Button Height="29" Width="111"> hello </Button>
</Expander>

The above code works. But:

<Expander Header="More options" Margin="281,218,39,12">
    <RichTextBox Name="richTextBox1" Margin="100,50,200,30" Height="30" Width="80">
        <FlowDocument>
            <Paragraph>Hi how are you?</Paragraph>
        </FlowDocument>
    </RichTextBox>
</Expander>

This will not work. Why? How to make this work?


Solution

  • Please remove the Margin and avoid setting static Height and Width, it will work.

    <Expander Header="More options" >
        <RichTextBox Name="richTextBox1" >
            <FlowDocument>
                <Paragraph>Hi how are you?</Paragraph>
            </FlowDocument>
        </RichTextBox>
    </Expander>