RichTextBox的“开始"与其文本之间的距离 [英] Getting distance between between 'start' of RichTextBox and its text

查看:89
本文介绍了RichTextBox的“开始"与其文本之间的距离的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要知道文本开头的位置RichTextBox.我将border,margin和padding设置为0,但位置仍然错误.见

<Window x:Class="TWPF.MainWindow"
        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"
        xmlns:local="clr-namespace:TWPF"
        mc:Ignorable="d"
        Title="MainWindow" Height="350" Width="500">
    <Canvas UseLayoutRounding="True">
        <RichTextBox Name="RTB" Border="0" Margin="0" Padding="0" Width="500">
            <FlowDocument PageWidth="{Binding ElementName=RTB, Path=ActualWidth}">
                <Paragraph TextIndent="-10" Margin="10,0,0,0" Padding="0" FontSize="9">
                    123 123 123 123123 123 123 123123 123 123 123123 123 123 123123 123 123 123123 123 123 123123 123 123 123123 123 123 123123 123 123 123123 123 123 123123 123 123 123123 123 123 123123 123 123 123123 123 123 123123 123 123 123
                </Paragraph>
            </FlowDocument>
        </RichTextBox>

        <Line X1="0" Y1="0" X2="0" Y2="50" Stroke="Red" StrokeThickness="1" />
        <Line X1="10" Y1="0" X2="10" Y2="50" Stroke="Red" StrokeThickness="1" />
    </Canvas>
</Window>

推荐答案

删除段落边距:

<FlowDocument PageWidth="{Binding ElementName=RTB, Path=ActualWidth}">
                <Paragraph TextIndent="-10" Margin="0" Padding="0" FontSize="9">
                    123 123 123 123123 123 123 123123 123 123 123123 123 123 123123 123 123 123123 123 123 123123 123 123 123123 123 123 123123 123 123 123123 123 123 123123 123 123 123123 123 123 123123 123 123 123123 123 123 123123 123 123 123
                </Paragraph>
            </FlowDocument>

,对于全部左缩进,也请删除TextIndent.

and for total left indentation remove TextIndent also.


这篇关于RichTextBox的“开始"与其文本之间的距离的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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