开发者

Create an Auto-sized RichTextBox in Custom WPF control (VB.NET)

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开发者_JS百科 allow the whole RTB to display on-screen.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜