【问题标题】:WPF: using RichTextBox / FlowDocument in ToolTipWPF:在工具提示中使用 RichTextBox / FlowDocument
【发布时间】:2012-12-16 19:34:51
【问题描述】:

我想使用 RichTextDocument / Flow 文档作为工具提示的内容,以在工具提示中获得更多格式功能。但是发生了一些奇怪的结果:

  • 如果在工具提示中使用 RichTextBox

    <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>
    

  • 如果直接在工具提示中使用 Flow 文档

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

您能建议正确的方法吗?如何禁用那个大预览窗口?也许流文档的使用不是最好的方法?我意识到我可以只添加 StackPanel 并用 TextBlocks 填充,但现在它在说明 FlowDocument 有什么问题? :)

【问题讨论】:

    标签: wpf tooltip richtextbox flowdocument


    【解决方案1】:

    FlowDocument 的默认DataTemplate 包含一个用于显示文档的FlowDocumentReader。如果不想在FlowDocumentPageViewerFlowDocumentScrollViewer 之间动态选择,可以直接使用。

    <Label.ToolTip>
        <FlowDocumentScrollViewer VerticalScrollBarVisibility="Auto">
            <FlowDocument>
                <Paragraph>Bla-bla</Paragraph>
            </FlowDocument>                    
        </FlowDocumentScrollViewer>
    </Label.ToolTip>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-09-10
      • 2017-01-28
      • 2011-06-17
      • 2019-05-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多