Question

I would like to use RichTextDocument / Flow document as content of tooltip to get more formatting features in tooltip. But some strange results happen:

  • If use RichTextBox inside tooltip

    <Label Name="sbLabelActions" Content="{Binding ActionsCount}" Style="{StaticResource ResourceKey=StatusBarLabelWithText}" MinWidth="40" >
        <Label.ToolTip>
            <RichTextBox>
                <FlowDocument><Paragraph>Bla-bla</Paragraph></FlowDocument>
            </RichTextBox>
        </Label.ToolTip>
    </Label>
    

enter image description here

  • If use Flow document directly inside tooltip

    <Label Name="sbLabelActions" Content="{Binding ActionsCount}" Style="{StaticResource ResourceKey=StatusBarLabelWithText}" MinWidth="40" >
        <Label.ToolTip>
                <FlowDocument><Paragraph>Bla-bla</Paragraph></FlowDocument>
        </Label.ToolTip>
    </Label>
    

enter image description here

Could you please suggest correct way? How to disable that BIG preview window? Maybe flow document usage is not the best way? I realize that I can just add StackPanel and fill with TextBlocks, but it's instresting now what's wrong with FlowDocument? :)

Was it helpful?

Solution

The default DataTemplate for FlowDocument contains a FlowDocumentReader that is used to display the document. If you don't want to dynamically choose between FlowDocumentPageViewer and FlowDocumentScrollViewer you can use them directly.

<Label.ToolTip>
    <FlowDocumentScrollViewer VerticalScrollBarVisibility="Auto">
        <FlowDocument>
            <Paragraph>Bla-bla</Paragraph>
        </FlowDocument>                    
    </FlowDocumentScrollViewer>
</Label.ToolTip>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top