locked
Horizontal scrolling doesn't work with ItemsStackPanel in ListView(GridView)

    Question

  • Hi,

    In Win 8.1 App Store Project I have a ListView with fixed width and listen for ContainerContentChanging event because of performance issues.

    When ListView width is less than content width, horizontal scrolling doesn't work. If we change ItemsStackPanel to VirtualizingStackPanel, horizontal scrolling works fine. But ContainerContentChanging doesn't work with VirtualizingStackPanel.

    Is it possible to make horizontal scrolling work with ItemsStackPanel?

    Here simple example to reproduce this problem:

    <Page
        x:Class="App8.MainPage"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="using:App8"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d">
        
        <Page.Resources>       
            <DataTemplate x:Key="ContinuousViewItemTemplate">
                <Border Width="800"
                        Background="Green"
                        Margin="10"
                        Padding="5">
                    <Border x:Name="root" Height="800" Background="{Binding}"/>
                </Border>
            </DataTemplate>
            
            <Style x:Key="ListViewStyle1" TargetType="ListView">
                <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Visible"/>
                <Setter Property="ScrollViewer.HorizontalScrollMode" Value="Enabled"/>
                <Setter Property="ItemTemplate" Value="{StaticResource ContinuousViewItemTemplate}"/>
            </Style>
        </Page.Resources>
    
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="100"/>
                <ColumnDefinition Width="500"/>
                <ColumnDefinition/>
                <ColumnDefinition Width="500"/>
                <ColumnDefinition Width="100"/>
            </Grid.ColumnDefinitions>
            <ListView Style="{StaticResource ListViewStyle1}" Grid.Column="1">
                <SolidColorBrush Color="Red"/>
                <SolidColorBrush Color="Cyan"/>
            </ListView>
            <ListView Style="{StaticResource ListViewStyle1}" Grid.Column="3">
                <ListView.ItemsPanel>
                    <ItemsPanelTemplate>
                        <VirtualizingStackPanel/>
                    </ItemsPanelTemplate>
                </ListView.ItemsPanel>
                <SolidColorBrush Color="Red"/>
                <SolidColorBrush Color="Cyan"/>
            </ListView>
        </Grid>
    </Page>
    

    Friday, October 18, 2013 1:08 PM

Answers

  • Hi Mikhail Maksyuta,

    Welcome back!

    Yes, you are right! I have reproduced it on VS 2013 professional.

    I will report it as bug, Thanks for your valuable suggestions!

    If you have any other questions about this, please feel free let me know!

    Thanks again!

    Regards! 


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, October 21, 2013 9:59 AM
    Moderator

All replies

  • Hi Mikhail Maksyuta,

    Welcome to MSDN forum!

    I have tested the sample but I couldn't reproduce your problem. I tested it on win8.1 with VS 2012.

    Regards!


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, October 21, 2013 2:33 AM
    Moderator
  • Hi Mikhail Maksyuta,

    Welcome to MSDN forum!

    I have tested the sample but I couldn't reproduce your problem. I tested it on win8.1 with VS 2012.

    Regards!

    Hi.

    Sorry, I forgot to clarify, that I use VS 2013. I've just tested this in VS 2012 and it realy works fine. But in VS 2013 this problem exist.

    Because of account verification I cannot insert image with bug. So, here link to screenshot 

    https://dl.dropboxusercontent.com/u/17028424/HorizontalScrollProblem.png


    Monday, October 21, 2013 7:12 AM
  • Hi Mikhail Maksyuta,

    Welcome back!

    Yes, you are right! I have reproduced it on VS 2013 professional.

    I will report it as bug, Thanks for your valuable suggestions!

    If you have any other questions about this, please feel free let me know!

    Thanks again!

    Regards! 


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, October 21, 2013 9:59 AM
    Moderator
  • Ran into the same issue.  Any ListView that has more items horizontally than the viewport size fails to scroll horizontally.  If I replace the ItemStackPanel with a WrapGrid, it scrolls, but then I can't use the TopHeader property of the ScrollViewer.  I could use a workaround to this if you don't have an actual fix.  Please check with the engineers and see if they have any suggestions.
    Tuesday, May 20, 2014 11:30 AM
  • You should set ListView properties:

    ScrollViewer.HorizontalScrollMode="Auto"
    ScrollViewer.VerticalScrollMode="Disabled"
    ScrollViewer.HorizontalScrollBarVisibility="Auto"
    ScrollViewer.VerticalScrollBarVisibility="Disabled"

    Then ItemsStackPanel property Orientation="Horizontal"

    • Proposed as answer by Stefan Fabian Monday, April 27, 2015 10:00 PM
    Tuesday, February 10, 2015 6:05 AM