TextRange构造函数扩展了所需的范围

时间:2016-03-01 15:51:30

标签: c# wpf richtextbox textrange

enter image description here

<RichTextBox Name="rtb" Margin="20">
    <FlowDocument>
        <Paragraph>Today is the day before tomorrow. Today is the day before tomorrow. Today is the day before tomorrow. Today is the day before tomorrow. Today is the day before tomorrow. Today is the day before tomorrow. Today is the day before tomorrow.</Paragraph>
        <Table CellSpacing="10"
               Padding="0"
               Background="Yellow"
               FontFamily="Arial"
               FontSize="12">
            <Table.Columns>
                <TableColumn Width="70" />
                <TableColumn Width="120" />
                <TableColumn Width="200" />
            </Table.Columns>
            <TableRowGroup Background="Gold">
                <TableRow>
                    <TableCell ColumnSpan="3">
                        <Paragraph Foreground="Gold" Background="Black" TextAlignment="Center" FontSize="16">Table Header</Paragraph>
                    </TableCell>
                </TableRow>
                <TableRow>
                    <TableCell BorderThickness="1" BorderBrush="Black">
                        <Paragraph>Cell 0,0</Paragraph>
                    </TableCell>
                    <TableCell BorderThickness="1" BorderBrush="Black">
                        <Paragraph>Cell 0,1</Paragraph>
                    </TableCell>
                    <TableCell BorderThickness="1" BorderBrush="Black">
                        <Paragraph>Cell 0,2</Paragraph>
                    </TableCell>
                </TableRow>
                <TableRow>
                    <TableCell BorderThickness="1" BorderBrush="Black">
                        <Paragraph>Cell 1,0</Paragraph>
                    </TableCell>
                    <TableCell BorderThickness="1" BorderBrush="Black">
                        <Paragraph>Cell 1,1</Paragraph>
                    </TableCell>
                    <TableCell BorderThickness="1" BorderBrush="Black">
                        <Paragraph>Cell 1,2</Paragraph>
                    </TableCell>
                </TableRow>
            </TableRowGroup>
        </Table>
        <Paragraph>Today is the day before tomorrow. Today is the day before tomorrow. Today is the day before tomorrow. Today is the day before tomorrow. Today is the day before tomorrow. Today is the day before tomorrow. Today is the day before tomorrow.</Paragraph>
    </FlowDocument>
</RichTextBox>

对于FindAgain,我需要从选择结束到文档结尾的TextRange

string rangeText = new TextRange(rtb.Selection.End, rtb.Document.ContentEnd).Text;

我希望rangeText以“1,1”开头,但它以“Cell 1,0”开头。然而,对我来说似乎很奇怪,我怎样才能获得所需的范围?

0 个答案:

没有答案