没有设置宽度的 WPF RichTextBox [英] WPF RichTextBox with no width set

查看:38
本文介绍了没有设置宽度的 WPF RichTextBox的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下 XAML 代码:

I have the following XAML code:

<Window x:Class="RichText_Wrapping.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1">
<Grid>
    <RichTextBox Height="100" Margin="2" Name="richTextBox1">
        <FlowDocument>
            <Paragraph>
                This is a RichTextBox - if you don't specify a width, the text appears in a single column
            </Paragraph>
        </FlowDocument>
    </RichTextBox>
</Grid>

... 如果您在 XAML 中创建此窗口,您可以看到当您没有为窗口指定宽度时,它会将文本包装在单列中,一次一个字母.有什么我想念的吗?如果这是控件中的已知缺陷,是否有任何解决方法?

... If you create this window in XAML, you can see that when you don't specify a width for the window, it wraps the text in a single column, one letter at a time. Is there something I'm missing? If it's a known deficiency in the control, is there any workaround?

推荐答案

尝试将 FlowDocument 的宽度(一种方式)绑定到容器 RichTextBox 的宽度.

Try binding the FlowDocument's width (one way) to the width of the container RichTextBox.

为我工作...

这篇关于没有设置宽度的 WPF RichTextBox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆