views:

258

answers:

1

I have previously used the arguments of a contentsResized event on a Winforms richtextbox to get the new size of my RTB.

I am now developing a WinForms app with a custom WPF RichTextBox. My whole reason for doing this is to use the out-of-the-box spellchecker.

I need my RichTextBox to expand and collapse vertically as the text is changed. The elementhost will also have to resize to allow the whole RTB to display on-screen.

Help! :)

+1  A: 

If what you want is to make your RichTextBox only be as high as needed, put it in a StackPanel like this

<Window x:Class="WpfApplication3.Window1"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Window1" Height="300" Width="300">
  <StackPanel>
    <RichTextBox Background="Azure" />
  </StackPanel>
</Window>

Otherwise please explain in more detail what your problem is, and if possible post the code that is not working.

Oskar
Thank you! Not only did this solve my problem but it actually got me pointed in a new direction that will RADICALLY improve my program's performance and UI feel. Thank you for taking the time to help!
Matt H.