WPF中的Expander里面的RichTextBox

时间:2013-07-19 15:08:45

标签: wpf xaml .net-4.0 richtextbox expander

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

以上代码有效。但是:

<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>

这不起作用。为什么?如何使这项工作?

1 个答案:

答案 0 :(得分:1)

请删除边距并避免设置静态高度和宽度,它将起作用。

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