locked
VirtualizingStackPanel,ScrollViewer and Mandatory snap not respected by mouse wheel

    Question

  • I have this Windows 8.1 guy

    <ItemsControl>
            <ItemsControl.ItemTemplate>
                <DataTemplate>
                    
                </DataTemplate>
            </ItemsControl.ItemTemplate>
            <ItemsControl.ItemsPanel>
                <ItemsPanelTemplate>
                    <VirtualizingStackPanel AreScrollSnapPointsRegular="True" Orientation="Horizontal"  />
                </ItemsPanelTemplate>
            </ItemsControl.ItemsPanel>
            <ItemsControl.Template>
                <ControlTemplate TargetType="ItemsControl">
                    <ScrollViewer x:Name="ScrollingHost" HorizontalSnapPointsType="MandatorySingle" HorizontalScrollMode="Enabled" HorizontalScrollBarVisibility="Hidden"
                                      VerticalScrollMode="Disabled" IsHorizontalScrollChainingEnabled="True" IsHorizontalRailEnabled="False"  BringIntoViewOnFocusChange="True"
                                      IsTabStop="False" ZoomMode="Disabled" VerticalScrollBarVisibility="Disabled" HorizontalSnapPointsAlignment="Near" 
                                      >
                        <ItemsPresenter />
                    </ScrollViewer>
                </ControlTemplate>
            </ItemsControl.Template>
        </ItemsControl>

    Note the HorizontalSnapPointsType="MandatorySingle". Now, user gesture works fine, keyboard arrows left and right work find - all snap to a DataTemplate control (omited in XAML).

    However scrolling using mouse wheel doesn't snap at all for some reason just stops wherever you leave it.

    But if substitute VirtualStackPanel with StackPanel mouse wheel starts snapping as expected. Any idea how to remedy this with a virtualized panel?


    Miha Markic [MVP C#] http://blog.rthand.com



    Tuesday, March 17, 2015 11:43 AM

All replies

  • I expect this is by-design. Virtualized data doesn't know how many items it's going to contain, so won't necessarily know where to stop as more items are added.

    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.

    Tuesday, March 17, 2015 3:24 PM
    Moderator
  • Hi Matt,

    Not really. Virtualization is about UI, not data. It knows exactly how many items there are, the template size and when using keyboard or swiping works, just when mouse wheel it doesn't.


    Miha Markic [MVP C#] http://blog.rthand.com

    Tuesday, March 17, 2015 3:53 PM
  • Fair enough.  Can you send me a repro project? If it's a bug, I'll file it using that project.

    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.

    Wednesday, March 18, 2015 2:40 PM
    Moderator
  • No problem, sample is at http://misc.rthand.com/mandatorywheel.rar.

    Miha Markic [MVP C#] http://blog.rthand.com


    Thursday, March 19, 2015 8:52 AM