locked
FooterTemplate in GridView horizontal orientation

    Question

  • I develop Win8.1 universal app.

    I'm using GridView with WrapGrid as ItemsPanel inside. Verticall scrolling is disabled, user needs to scroll horizontally only. I'm using incremental source collection as ItemsSource and when user scrolls right to the end of the GridView, new items are dynamically added. Everything works fine, except one thing. I want to make a progress indicator right-aligned and it must become visible when new page is loading. I try to set footer template for grid view, but it is hidden (bc maybe by default footer is added below the itemspanel or whatever).

    Here is the code i use to define control template for GridView and put Footer right.

    <GridView.Template>
                        <ControlTemplate TargetType="GridView">
                            <Border BorderBrush="{TemplateBinding BorderBrush}"
                                    BorderThickness="{TemplateBinding BorderThickness}" 
                                    Background="{TemplateBinding Background}">
                                <ScrollViewer x:Name="ScrollViewer" 
                                              AutomationProperties.AccessibilityView="Raw"
                                              BringIntoViewOnFocusChange="{TemplateBinding ScrollViewer.BringIntoViewOnFocusChange}" 
                                              HorizontalScrollMode="{TemplateBinding ScrollViewer.HorizontalScrollMode}" 
                                              HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}" 
                                              IsHorizontalRailEnabled="{TemplateBinding ScrollViewer.IsHorizontalRailEnabled}" 
                                              IsHorizontalScrollChainingEnabled="{TemplateBinding ScrollViewer.IsHorizontalScrollChainingEnabled}" 
                                              IsVerticalScrollChainingEnabled="{TemplateBinding ScrollViewer.IsVerticalScrollChainingEnabled}" 
                                              IsVerticalRailEnabled="{TemplateBinding ScrollViewer.IsVerticalRailEnabled}" 
                                              IsDeferredScrollingEnabled="{TemplateBinding ScrollViewer.IsDeferredScrollingEnabled}" 
                                              TabNavigation="{TemplateBinding TabNavigation}" 
                                              VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}" 
                                              VerticalScrollMode="{TemplateBinding ScrollViewer.VerticalScrollMode}" 
                                              ZoomMode="{TemplateBinding ScrollViewer.ZoomMode}">
                                    <StackPanel Orientation="Horizontal">
                                        <ItemsPresenter HeaderTemplate="{TemplateBinding HeaderTemplate}"
                                                        Header="{TemplateBinding Header}"
                                                        HeaderTransitions="{TemplateBinding HeaderTransitions}"
                                                        Padding="{TemplateBinding Padding}"/>
                                        <ContentControl Transitions="{TemplateBinding FooterTransitions}"
                                                        ContentTemplate="{TemplateBinding FooterTemplate}" 
                                                        Content="{TemplateBinding Footer}"/>
                                    </StackPanel>
                                </ScrollViewer>
                            </Border>
                        </ControlTemplate>
                    </GridView.Template>

    Then i set ProgressRing as footer template.

    <GridView.FooterTemplate>
                        <DataTemplate>
                            <ProgressRing VerticalAlignment="Stretch"
                                          HorizontalAlignment="Stretch"
                                          IsActive="{Binding IsBusy}"
                                          Margin="0,24"
                                          Width="50"
                                          Height="50"
                                          Foreground="{StaticResource LightGreyBorderBrush}"
                                          Style="{StaticResource ProgressRingStyle}" />
                        </DataTemplate>
                    </GridView.FooterTemplate>

    But when i try to scroll - the things are going crazy. GridView always calls next page loading one after another, but the scroll position is nearly 0 (in the beginning of the GridView). So i get the infinite page loading.

    Can anyone help me with this? Many thanks in advance!


    Wednesday, October 15, 2014 1:43 PM

All replies

  • What exactly do you mean by "infinite page loading"?

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Thursday, October 16, 2014 1:09 PM
    Moderator
  • Matt,

    Thanks for your answer! By this i meant that GridView begins to call 'LoadNextPage' one after another and the position of scrollbar is always changed, but user do nothing, no touches, no interaction.

    I've created a small sample to reproduce - link. I will be very glad if you take a look.

    Many thanks!

    Friday, October 17, 2014 8:27 AM
  • This happens even when I remove the footer. I'm still investigating this.


    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Friday, October 17, 2014 6:32 PM
    Moderator