none
Why doesn't Flowdocument's tooltip show?

    Question

  • I have a very strange problem with tooltips inside FlowDocument. Finally I am able to narrow it down to the following xaml. Paste the following xaml into kaxaml or Blend, you will see the problem.
        <FlowDocumentScrollViewer>
            <FlowDocument Background="Transparent">
                <Table>
                    <Table.Columns>
                        <TableColumn Width="15" />
                        <TableColumn />
                    </Table.Columns>
                    <TableRowGroup>
                        <TableRow>
                            <TableCell>
                                <Paragraph Margin="0,3.10333333333333,0,0">
                                    <Run FontSize="5"></Run>
                                </Paragraph>
                            </TableCell>
                            <TableCell>
                                <Paragraph>
                                    <Run FontSize="13"
                                         ToolTip="This is a tooltip">I have a tooltip</Run>
                                </Paragraph>
                                <Paragraph LineHeight="0.1"
                                           Background="Transparent">
                                    <Figure Name="MyFigure"
                                            HorizontalAnchor="ColumnLeft"
                                            VerticalAnchor="ParagraphTop"
                                            CanDelayPlacement="False"
                                            Width="200"
                                            Padding="0,0,0,0">
                                        <BlockUIContainer>
                                            <Grid>
                                                <Rectangle Name="MyRectangle"
                                                           Fill="Green"
                                                           Width="Auto"
                                                           Height="50" />
                                            </Grid>
                                        </BlockUIContainer>
                                    </Figure>
                                </Paragraph>
                            </TableCell>
                        </TableRow>
                    </TableRowGroup>
                </Table>
            </FlowDocument>
        </FlowDocumentScrollViewer>
    

    The tooltip doesn't open. However if I do one of the following, the tooltip will show.
     - Change MyFigure's Width to 15
     - Change MyRectangle's Height to 5
    It almost feels like the Run is covered by something so its tooltip doesn't show. Is this a bug?
    Thursday, September 22, 2011 1:43 AM

All replies

  • Hey Kai, good day to you.

    I've tried to look for the root cause of this strange effect and I've found that it has something to do with the rectangle and it indicated that something is covering the "Run" but I've found a workaround for this problem which will be the following:

    <TableCell>
                                    <Paragraph>
                                        <Run FontSize="13"
                                         ToolTip="This is a tooltip">I have a tooltip
                                        </Run>
                                    </Paragraph>
                                    <Paragraph></Paragraph>
                                    <Paragraph LineHeight="0.1"
                                           Background="Black">
                                        <Figure Name="MyFigure"
                                            HorizontalAnchor="ColumnCenter"
                                            VerticalAnchor="ContentCenter"
                                            CanDelayPlacement="False"
                                            Padding="0,0,0,0">
                                            <BlockUIContainer>
                                                <Grid>
                                                    <Rectangle Name="MyRectangle"
                                                           Fill="Green"
                                                           Width="Auto"
                                                           Height="50" />
                                                </Grid>
                                            </BlockUIContainer>
                                        </Figure>
                                    </Paragraph>
                                </TableCell>
    

    You may have noticed the empty paragraph between the Run and the Shape. I guess this makes things a little bit clearer.


    Please, mark my reply as Answer if it helps or vote it up if it gives a key to the solution.
    Thanks in advance and good luck.
    Ahmed M. Gamil
    "It is not titles that honor men, but men that honor titles."
    Thursday, September 22, 2011 8:48 AM
  • That's also one of the workarounds I have found. It proves that something does place on top the Run with the tooltip. However I can't use this workaround since I need very fine control on the spacing between any two blocks.

    Thursday, September 22, 2011 12:39 PM
  • Hi Kai Wang,

    I spent lots of time on your issue, I think if you set "LineHeight="0.1", second "Paragraph" will cover your first one, so the Run element will not get mouseover, so the tooltip will work as well, I think you could add a Table Row to achieve your goal:

            <FlowDocumentScrollViewer>
                <FlowDocument Background="Transparent">
                    <Table>
                        <Table.Columns>
                            <TableColumn Width="15" />
                            <TableColumn Width="200">
                               
                            </TableColumn>
                        </Table.Columns>
                       
                        <TableRowGroup>
                            <TableRow>
                                <TableCell>
                                    <Paragraph Margin="0,3.10333333333333,0,0">
                                        <Run FontSize="5"></Run>
                                    </Paragraph>
                                </TableCell>
                                <TableCell>
                                    <Paragraph>
                                        <Run FontSize="13"
                                         ToolTip="This is a tooltip">I have a tooltip</Run>
                                    </Paragraph >
                                </TableCell>
                            </TableRow>
                            <TableRow>
                                <TableCell>
                                    <Paragraph Margin="0,3.10333333333333,0,0">
                                       
                                    </Paragraph>
                                </TableCell>
                                <TableCell>
                                <Paragraph   LineHeight="0.1"
                                           Background="Transparent">
                                        <Figure Name="MyFigure"
                                            HorizontalAnchor="ColumnLeft"
                                            VerticalAnchor="ParagraphTop"
                                            CanDelayPlacement="False"
                                            Width="200"
                                            Padding="0,0,0,0">
                                            <BlockUIContainer>
                                                <Grid>
                                                    <Rectangle Name="MyRectangle"
                                                           Fill="Green"
                                                           Width="200"
                                                           Height="50" />
                                                </Grid>
                                            </BlockUIContainer>
                                        </Figure>
                                    </Paragraph>
                                </TableCell>
                            </TableRow>
                        </TableRowGroup>
                    </Table>
                </FlowDocument>
            </FlowDocumentScrollViewer>
    

     

    Best regards,


    Sheldon _Xiao[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, September 23, 2011 6:10 AM
  • Any updates?
    Sheldon _Xiao[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, September 26, 2011 4:31 AM
  • Sheldon, 

    Thanks for the reply.

    To answer your question, no, the problem persists without LineHeight=0.1.

    Monday, November 21, 2011 3:50 PM
  • Hi Kai Wang,

    Have you tried my xaml code, it works well if you use table, I have tested it on my side.


    Sheldon _Xiao[MSFT]
    MSDN Community Support | Feedback to us
    Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, November 22, 2011 3:36 AM