代码之家  ›  专栏  ›  技术社区  ›  Echilon

flowdocumentscrollviewer不会滚动

  •  0
  • Echilon  · 技术社区  · 15 年前

    我想找到最可行的方法来展示 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 ,还是我遗漏了什么?

    3 回复  |  直到 10 年前
        1
  •  1
  •   Dave Clemmer manu    10 年前

    我最终通过设置 ListBox 在文档中 IsHitTestVisible="false" ,然后绑定 Width 中的文本块 ListBoxItem 模板到 ActualWidth 列表项目 .

        2
  •  0
  •   KV Prajapati    15 年前

    Flexible Content Display With Flow Documents

    摘要:流文档滚动查看器- 此控件在 有滚动条的连续流动, 类似于网页或网页布局 在Microsoft Word中。

        3
  •  0
  •   Dave Clemmer manu    10 年前

    对我来说另一个选择 FlowDocumentScrollViewer 工作,

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

    其他的选择可能是 FlowDocumentPageViewer , FlowDocumentReader .