Arsen Zahray
Arsen Zahray

Reputation: 25287

Autogrow WPF RichTextBox

You can do the trick with TextBox: when you set AcceptReturn=true, the TextBox will grow as you add new lines of text.

Is it possible to do the same to RichTextBox?

I'm doing this in WPF

Upvotes: 2

Views: 612

Answers (1)

dharmatech
dharmatech

Reputation: 9517

Yes. By default, RichTextBox accepts return and will grow accordingly. For example, this RichTextBox will grow:

<Window x:Class="stackoverflow___rich_text_box___accepts_return.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">
    <StackPanel>
        <RichTextBox/>
    </StackPanel>
</Window>

You'd have to do this:

<RichTextBox AcceptsReturn="False"/>

to get it not to grow.

Upvotes: 1

Related Questions