FlowDocumentScrollViewer 不会滚动

发布于 2024-08-04 13:08:40 字数 1385 浏览 7 评论 0原文

我正在尝试找到最可扩展的方式来在窗口内显示 FlowDocument - 只是一个 FlowDocument。我有:

<FlowDocumentScrollViewer x:Name="message" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Visible">

然后在窗口的构造函数中,我将查看器的文档设置为从 XAML 加载的文档(在代码中)。 XAML 包含:

<FlowDocument xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
          xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Background="{x:Null}"
          FontSize="12" FontFamily="Segoe UI"  PagePadding="2">
<BlockUIContainer>
    <BlockUIContainer.Resources>
        <Style TargetType="{x:Type TextBlock}">
            <Setter Property="TextWrapping" Value="Wrap"/>
        </Style>
    </BlockUIContainer.Resources>
    <StackPanel MaxWidth="200">
        <TextBlock Text="{Binding DefinedWord}" FontWeight="Bold"  />
        <ListBox ItemsSource="{Binding Definitions}"
                 Style="{StaticResource InvisibleListBox}" Margin="0"
                 ScrollViewer.HorizontalScrollBarVisibility="Disabled" 
                 ScrollViewer.VerticalScrollBarVisibility="Disabled" 
                 ScrollViewer.CanContentScroll="false">
...

无论我尝试什么,FlowDocumentScrollViewer 都不会滚动,并且我看不到文档的截断部分。它与 BlockUIContainer 有什么关系,还是我错过了其他东西?

I'm trying to find the most expandable way to show a FlowDocument inside a window - just a FlowDocument. I have:

<FlowDocumentScrollViewer x:Name="message" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Visible">

Then in the constructor for the Window, I set the Document of the viewer to one I load from XAML (in code). The XAML contains:

<FlowDocument xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
          xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Background="{x:Null}"
          FontSize="12" FontFamily="Segoe UI"  PagePadding="2">
<BlockUIContainer>
    <BlockUIContainer.Resources>
        <Style TargetType="{x:Type TextBlock}">
            <Setter Property="TextWrapping" Value="Wrap"/>
        </Style>
    </BlockUIContainer.Resources>
    <StackPanel MaxWidth="200">
        <TextBlock Text="{Binding DefinedWord}" FontWeight="Bold"  />
        <ListBox ItemsSource="{Binding Definitions}"
                 Style="{StaticResource InvisibleListBox}" Margin="0"
                 ScrollViewer.HorizontalScrollBarVisibility="Disabled" 
                 ScrollViewer.VerticalScrollBarVisibility="Disabled" 
                 ScrollViewer.CanContentScroll="false">
...

No matter what I try, the FlowDocumentScrollViewer does not scroll and I can't see the truncated parts of the document. Does it have anything to do with the BlockUIContainer, or am I missing something else?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

扭转时空 2024-08-11 13:08:40

我最终通过将文档内的 ListBox 设置为 IsHitTestVisible="false" 来实现此工作,然后绑定文本块内的 WidthListBoxItem 模板设置为 ListBoxItemActualWidth

I eventually got this working by setting the ListBox inside the document to IsHitTestVisible="false", then binding the Width of a text block inside the ListBoxItem template to the ActualWidth of the ListBoxItem.

无语# 2024-08-11 13:08:40

使用流程文档灵活显示内容

摘要:FlowDocumentScrollViewer -
该控件显示文档
带滚动条的连续流,
类似于网页或网页布局
在 Microsoft Word 中。

Flexible Content Display With Flow Documents

SUMMARY: FlowDocumentScrollViewer -
This control displays documents in a
continuous flow with a scrollbar,
similar to Web pages or the Web Layout
in Microsoft Word.

一向肩并 2024-08-11 13:08:40

对我来说,FlowDocumentScrollViewer 的替代选项有效,

请参阅以下示例:
http://msdn.microsoft.com/en-us /library/system.windows.controls.richtextbox.aspx

其他选项可能是 FlowDocumentPageViewerFlowDocumentReader

For me alternate option to FlowDocumentScrollViewer worked,

See the example in,
http://msdn.microsoft.com/en-us/library/system.windows.controls.richtextbox.aspx

The other options may be FlowDocumentPageViewer, FlowDocumentReader.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文