How to manually scroll using ItemsRepeater

旧时模样 提交于 2020-01-16 17:11:18

问题


I'm using ItemsRepeater. And using a ScrollViewer to scroll left/right.

For some reason, I have to disable ScrollViewer' HorizontalScrollMode, and add Left/Right Button to manual scroll.

The xaml is

<Grid>
                    <muxc:ItemsRepeaterScrollHost Margin="12" Loaded="ItemsRepeaterScrollHost_Loaded">
                        <ScrollViewer
                            x:Name="sss"
                            VerticalScrollBarVisibility="Hidden"
                            HorizontalScrollBarVisibility="Hidden"
                            VerticalScrollMode="Disabled"
                            HorizontalScrollMode="Disabled">
                            <muxc:ItemsRepeater
                                x:Name="HorizontalRepeater"
                                ItemsSource="{x:Bind product}"
                                ItemTemplate="{StaticResource HorizontalTemplate}">
                                <muxc:ItemsRepeater.Layout>
                                    <muxc:StackLayout Orientation="Horizontal" Spacing="12"/>
                                </muxc:ItemsRepeater.Layout>
                            </muxc:ItemsRepeater>
                        </ScrollViewer>
                    </muxc:ItemsRepeaterScrollHost>
                    <Button
                        x:Name="ButtonLeft"
                        Tapped="ButtonLeft_Tapped">
                        <FontIcon FontFamily="Segoe MDL2 Assets" Glyph="&#xE76B;" FontSize="18" />
                    </Button>

                    <Button x:Name="ButtonRight"
                        Tapped="ButtonRight_Tapped">
                        <FontIcon FontFamily="Segoe MDL2 Assets" Glyph="&#xE76C;" FontSize="18" />
                    </Button>
                </Grid>

Then I use

sss.ChangeView(step, null, null);

Nothing happens. Why, thx.


回答1:


How to manually scroll using ItemsRepeater

For my testing, ChangeView can't works for ItemsRepeater, Please try replace it with ScrollToHorizontalOffset or ScrollToVerticalOffset method.

Update

After update OS to latest version (1909) ChangeView works well, It may be a issue within previous version.



来源:https://stackoverflow.com/questions/58815861/how-to-manually-scroll-using-itemsrepeater

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!