Pages Changing

Nov 9, 2010 at 4:46 PM

I have a document viewer and it's showing thumbnails.  When I change pages using the page navigator everything seems to work but the page never moves.  The same thing happens if I use thumbnails or even if I do a search using the search results to change pages.

I'm using the Form Fill Behavior, so it has a templated scrollviewer, but it doesn't move unless I move the scroll bar manually.

Nov 9, 2010 at 9:26 PM

Here's a snippet of the XAML:

 
    <UserControl.Resources>
        <vm:FormViewModel x:Key="vm" />
    </UserControl.Resources>
    <ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
        <Grid x:Name="LayoutRoot" Background="White">
            <Grid.Resources>
                <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1" x:Key="BackgroundBrush">
                    <GradientStop Offset="0.0" Color="#D4D6DA" />
                    <GradientStop Offset="0.137" Color="#CACDD1" />
                    <GradientStop Offset="0.138" Color="#BAC1CA" />
                    <GradientStop Offset="0.95" Color="#E8ECF4" />
                    <GradientStop Offset="1.0" Color="#ACAFB7" />
                </LinearGradientBrush>
            </Grid.Resources>
            <Grid.ColumnDefinitions>
                <ColumnDefinition />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="30" />
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>

            <StackPanel x:Name="spNavigator" Grid.Row="0" Grid.ColumnSpan="2" HorizontalAlignment="Stretch" Orientation="Horizontal" Background="{StaticResource BackgroundBrush}">
                <doc:PageNavigator x:Name="PageNavigator" Margin="0,0,0,0"
                     PageCount="{Binding PageCount, ElementName=Viewer}"
                     PageIndex="{Binding PageIndex, ElementName=Viewer, Mode=TwoWay}"/>
                <doc:ViewModePicker x:Name="ViewModePicker" Margin="4" />
                <!-- Search, Thumbnail Preview, Zoom-->
                <TextBox x:Name="txtSearch" Width="140" Margin="4" Text="{Binding SearchText, Mode=TwoWay}" />
                <Button Content="Search" Margin="4" Command="{Binding SearchCommand}" CommandParameter="{Binding ElementName=LayoutRoot}" />
                <Button Content="Thumbnails" Margin="4" x:Name="btnThumbnails" Command="{Binding ThumbnailsCommand}" CommandParameter="{Binding ElementName=LayoutRoot}" />
                <Button Content="Save" Margin="4" Command="{Binding SaveFormCommand}"  />
                <Button Content="Cancel" Margin="4" Command="{Binding CancelFormCommand}" />
                <Button Content="Select" Margin="4" x:Name="btnSelect"  />
            </StackPanel>
            <doc:DocumentViewer x:Name="Viewer"
                            DocumentDataSource="{Binding DataSource}" Grid.Row="1" Grid.Column="0" Background="{StaticResource BackgroundBrush}" ViewMode="{Binding SelectedViewMode, ElementName=ViewModePicker}">
                <doc:DocumentViewer.Selection>
                    <doc:TextSelection IsEnabled="True" />
                </doc:DocumentViewer.Selection>
                <doc:DocumentViewer.Template>
                    <ControlTemplate TargetType="doc:DocumentViewer">
                        <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
                            <ScrollViewer x:Name="ScrollViewer" Background="Transparent" BorderThickness="0" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
                                <ItemsControl x:Name="Pages">
                                    <i:Interaction.Behaviors>
                                        <doc:PageVirtualizer />
                                    </i:Interaction.Behaviors>
                                    <ItemsControl.ItemTemplate>
                                        <DataTemplate>
                                            <Grid Width="{Binding DesiredPageContainerSize.Width}" Height="{Binding DesiredPageContainerSize.Height}">
                                                <Border Background="White" BorderBrush="{StaticResource SliderTrackBrush}" BorderThickness="1" Margin="4" HorizontalAlignment="Center" VerticalAlignment="Center">
                                                    <doc:FixedPageViewer FixedPage="{Binding FixedPage}" 
                                                                     FixedPageSize="{Binding FixedPageSize}"
                                                                     FixedPageError="{Binding FixedPageError}"
                                                                     Scale="{Binding DesiredPageScale}">
                                                        <i:Interaction.Behaviors>
                                                            <!-- enable form filling -->
                                                            <r:FormFillBehavior FormTypeGuid="{Binding FormTypeGuid, Source={StaticResource vm}}"  />
                                                        </i:Interaction.Behaviors>
                                                    </doc:FixedPageViewer>
                                                </Border>
                                            </Grid>
                                        </DataTemplate>
                                    </ItemsControl.ItemTemplate>
                                </ItemsControl>
                            </ScrollViewer>
                        </Border>
                    </ControlTemplate>
                </doc:DocumentViewer.Template>
            </doc:DocumentViewer>
            <StackPanel Width="150" HorizontalAlignment="Right" Grid.Row="1" Grid.Column="1" Visibility="{Binding SearchResultsVisible}">
                <TextBlock Text="Search Results" FontWeight="Bold" Margin="5" />
                <ListBox x:Name="lbSearchResults" BorderBrush="{x:Null}" SelectionChanged="SearchResults_SelectionChanged" ItemsSource="{Binding SearchResults}" DisplayMemberPath="Value" Margin="0"  />
            </StackPanel>
            <StackPanel Width="150" HorizontalAlignment="Right" Visibility="{Binding ThumbnailsVisible}" Grid.Row="1" Grid.Column="1">
                <doc:ThumbnailListBox x:Name="Thumbnails" DocumentDataSource="{Binding DataSource}"
                      PageIndex="{Binding PageIndex, Mode=TwoWay, ElementName=PageNavigator}" BorderBrush="{x:Null}" />
            </StackPanel>
        </Grid>
    </ScrollViewer>

Coordinator
Nov 10, 2010 at 11:16 AM

Hi inturbidus,

You mean that the selected page does not scroll into view when selected with the page navigator and/or page thumbnail listbox? Are there any binding errors?
If possible send me (kozw@firstfloorsoftware.com) the source, so I can look into it.

- Koen