如何在 RichTextBox 中显示 TableCell 的工具提示

How to Show the Tooltip of a TableCell in a RichTextBox

我在RichTextBox中插入一个Table,添加Table单元格s 使用给定的 工具提示 。像这样:

Table table = new Table();
table.Columns.Add(new TableColumn());
table.RowGroups.Add(new TableRowGroup());
TableRow r = new TableRow();
table.RowGroups[0].Rows.Add(r);
var ci = new TableCell(new Paragraph(new Run("Text here")));
ci.ToolTip = "tooltip to be displayed";
r.Cells.Add(ci);

或者这个:

<RichTextBox  IsReadOnly="True">
     <FlowDocument >
         <Table>
             <TableRowGroup>
                 <TableRow>
                      <TableCell ToolTip="This is a tooltip">
                            <Paragraph>
                                 <Run>......somthing......</Run>
                            </Paragraph>
                      </TableCell>
                 </TableRow>
              </TableRowGroup>
          </Table>
      </FlowDocument>
</RichTextBox>

但这不起作用。我检查了一下 PreviewMouseMove 事件被触发 TableCells。

感谢任何帮助。

您需要允许在禁用的控件上显示工具提示:

<RichTextBox  IsReadOnly="True">
    <FlowDocument >
        <Table>
            <TableRowGroup>
                <TableRow>
                    <TableCell BorderThickness="2" BorderBrush="Black" ToolTip="This is a tooltip" ToolTipService.ShowOnDisabled="True">
                        <Paragraph>
                            <Run>......something......</Run>
                        </Paragraph>
                    </TableCell>
                </TableRow>
            </TableRowGroup>
        </Table>
    </FlowDocument>
</RichTextBox>

设置ToolTipServices.ShowOnDisabled="True",像这样:

 <RichTextBox  IsReadOnly="True">
            <FlowDocument >
                <Table>
                    <TableRowGroup>
                        <TableRow>
                            <TableCell 
                                ToolTip="This is a tooltip" 
                                ToolTipService.ShowOnDisabled="True">
                                <Paragraph>
                                    <Run>......somthing......</Run>
                                </Paragraph>
                            </TableCell>
                        </TableRow>
                    </TableRowGroup>
                </Table>
            </FlowDocument>
        </RichTextBox>