有没有一种简单的方法可以防止 WPF RichTextBox 自动增长?

Is there a simple way to prevent a WPF RichTextBox from autogrowing?

这可能是个愚蠢的问题,但正如标题所说:有没有一种简单的方法可以防止 RichTextBox 在您向其添加更多行时增加其高度?

到目前为止我测试的内容:

None 但是上面的有帮助。 RTB 位于自动调整大小的网格行内,用户可以使用 GridSplitter 控制行高。随着更多文本的提交,我希望 RTB 尊重拆分器而不是 auto-resize。

非常感谢任何提示或建议!

[编辑] 顺便说一句,值得注意的是,一旦我调整 Grid.Row 的大小(使用 GridSplitter),RTB 就会受到限制,无法再自动增长。我想如果我能以某种方式模拟 resizing ,只是一个像素,当表单加载时它会 "solve" 问题。当然有点黑...

[编辑](相关 XAML 示例)

<Window
x:Class="Test.Window"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Title="TEST" 
Height="609.8" Width="848"
Background="#000000"
FontFamily="Segoe UI"
>
<Grid>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="50" />
        <ColumnDefinition Width="150" MinWidth="100"/>
        <ColumnDefinition Width="3"/>
        <ColumnDefinition Width="*"/>
    </Grid.ColumnDefinitions>
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto" />
        <RowDefinition Height="*" />
        <RowDefinition Height="3" />
        <RowDefinition Height="Auto" MinHeight="100" />
        <RowDefinition Height="Auto" />
    </Grid.RowDefinitions>
    <StackPanel 
            Grid.Row="1" Grid.Column="0" 
            Orientation="Vertical"
            Background="#333333"
            >
    </StackPanel>
    <Grid 
            Grid.Row="1"  Grid.Column="1"
            Width="Auto"
            HorizontalAlignment="Stretch"
            Background="#222222"
        />
    <GridSplitter 
            Grid.Row="1" Grid.Column="2" 
            HorizontalAlignment="Stretch" Width="3" Background="#222222" 
            />
    <Grid
            Grid.Row="1" Grid.Column="3"
            MinWidth="100"
            />
    <GridSplitter
            Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="4"
            HorizontalAlignment="Stretch" Height="3" Background="#222222" />
    <Grid Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="4">
        <Grid>
            <RichTextBox MinHeight="50" VerticalAlignment="Stretch">
                <RichTextBox.Document>
                    <FlowDocument>
                        <Paragraph>
                            <Run Text="Lorem ipsum dolor sit amet consectetur adipiscing elit tempor, class a cum odio diam nec ullamcorper eget, duis curae dictum rutrum cursus tristique rhoncus. Curabitur montes erat sociis feugiat dictumst eu faucibus, dapibus habitasse platea parturient dignissim fringilla tortor, et ridiculus vehicula ac vel sem."></Run>
                        </Paragraph>
                    </FlowDocument>
                </RichTextBox.Document>
            </RichTextBox>
        </Grid>
    </Grid>
</Grid>

一个简单的方法,给RTB(或者RTB所在的Grid Row)设置一个高度。

它一直在增长,因为没有固定的界限。它的父级 Grid 与其子级自动调整大小,因此子级被宠坏了。