Echilon
Echilon

Reputation: 10244

FlowDocumentScrollViewer won't scroll

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?

Upvotes: 1

Views: 2324

Answers (3)

Dotnet coder
Dotnet coder

Reputation: 21

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.

Upvotes: 0

Echilon
Echilon

Reputation: 10244

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.

Upvotes: 2

KV Prajapati
KV Prajapati

Reputation: 94645

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.

Upvotes: 0

Related Questions